Hi,
The table outputted by proc freq do not have the same structure i.e.
What would you suggest to have exactly the same variables in all the output datasets before appending them?
ods output OneWayFreqs(match_all)=demo;
proc freq data=sashelp.class nlevels;
table _all_;
run;
data freq_all;
set demo:;
run;
proc print data=freq_all;
run;
Thanks
PROC FREQ does not require that you use MATCH_ALL any more. I would suggest the following SAS Sample which creates one output data set and then reshapes it into a more readable format.
Hi @xxformat_com,
A common variable VARVALUE containing NAME and AGE values must be a character variable. This is what PROC TRANSPOSE creates when transposing from wide to long. Then you can apply PROC FREQ to the "long" dataset.
Example:
data tmp / view=tmp;
seqno=_n_;
set sashelp.class;
run;
proc transpose data=tmp name=varname out=long(drop=seqno rename=(col1=varvalue));
by seqno;
var name--weight;
run;
proc sort data=long;
by varname;
run;
proc freq data=long noprint;
by varname;
tables varvalue / out=want;
run;
PROC FREQ does not require that you use MATCH_ALL any more. I would suggest the following SAS Sample which creates one output data set and then reshapes it into a more readable format.
One of the advantages of @Kathryn_SAS's solution is that (by virtue of the VVALUEX function) it would honor formats that are permanently associated with variables in the input dataset. My PROC TRANSPOSE approach would do so only for numeric variables (and it creates an additional dataset, albeit with optimized lengths of variables VARNAME and VARVALUE).
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.