A dataset has 10 variables ('a' through 'f'), half quantitative and half categorical, and you want to generate a separate visual representation of each of these variables (histograms for the quantitative and bars for the categorical) with the minimum number of statements.
PROC UNIVARIATE can be used with quantitative variables and accepts multiple variables in the HISTOGRAM statement:
WORKING EXAMPLE: PROC UNIVARIATE takes multiple variables in the HISTOGRAM statement
proc univariate data=DATA noprint;
histogram a b c d e;
run;
which outputs five separate histograms, one for each variable. But PROC UNIVARIATE cannot output bar charts for the categorical variables, and PROC FREQ only has statements which output tables.
PROC SGPLOT has both the HISTOGRAM and HBAR/VBAR statements, but does not accept multiple variable arguments in the manner that PROC UNIVARIATE does.
INVALID EXAMPLE: SGPLOT does not accept multiple variables in the HISTOGRAM or HBAR/VBAR statements.
proc sgplot data=DATA;
vbar f g h i j;
run;
throws the following errors at the character between 'f' and 'g':
ERROR 22-322: Syntax error, expecting one of the following: ;, /.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
Is the only solution to write a separate SGPLOT statement for each categorical variable as below?
WORKING EXAMPLES: Single variable per statement
proc sgplot data=DATA;
vbar f;
run;
successfully generates a VBAR for 'f', and
proc sgplot data=DATA;
vbar g;
run;
successfully generates a VBAR for 'g'.
For a dataset with few variables this may not be difficult, but what about for large datasets?