ODS OUTPUT
is the best way to get information that you can print to the screen into datasets. Use ODS TRACE ON;
before your code, run it, then inspect the log; see what table name matches what you're looking for. Then use ODS OUTPUT <tablename>=<datasetname>
.
For example, in this PROC FREQ
, I see ONEWAYFREQS
is the table I want.
ods trace on;
proc freq data=sashelp.class;
var age;
run;
ods trace off;
So I use ODS OUTPUT:
ods output onewayfreqs=ages;
proc freq data=sashelp.class;
table age;
run;
ods output close;
and get a nice dataset. (ODS TRACE
is not necessary if you know the name of the table you're looking for.)