I am still trying to get the tables from Results window to a more user friendly medium. I have used the following code from an earlier helpful solution. I have listed the results from largest value to smallest value.
ods output generatedtable = SASCDC_2.Arias_contacts_2_Freq; proc freq data = SASCDC_2.Arias_contacts_CCO_2 order = freq; table American_Indian_and_Alaska_Nativ Black_or_African_American Hispanic_or_Latino_a_x Asian Middle_Eastern_North_African White Native_Hawaiian_and_Pacific_Isla / list out = SASCDC_2.Arias_contacts_2_Freq; run; ods trace off;
However the problem is pin-pointed in the log
ods output generatedtable = SASCDC_2.Arias_contacts_2_Freq; 151 proc freq data = SASCDC_2.Arias_contacts_CCO_2 order = freq; 152 table American_Indian_and_Alaska_Nativ Black_or_African_American Hispanic_or_Latino_a_x Asian 152! Middle_Eastern_North_African 153 White Native_Hawaiian_and_Pacific_Isla / list 154 out = SASCDC_2.Arias_contacts_2_Freq; 155 run; WARNING: Output 'generatedtable' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used. NOTE: There were 177244 observations read from the data set SASCDC_2.ARIAS_CONTACTS_CCO_2. NOTE: The data set SASCDC_2.ARIAS_CONTACTS_2_FREQ has 13 observations and 3 variables. NOTE: Compressing data set SASCDC_2.ARIAS_CONTACTS_2_FREQ increased size by 100.00 percent. Compressed is 2 pages; un-compressed would require 1 pages. NOTE: PROCEDURE FREQ used (Total process time): real time 0.90 seconds cpu time 0.51 seconds 156 ods trace off;
I am not specifying generatedtable correctly, among other things. Is there way to use the separate tables (I have 7 tables) and share with others one table per page, for example.
I am not grasping the intricacies of ods to make this work. Also I cannot find a tab called Details.
Thank you.
wklierman
See this example that's more specific to PROC FREQ, which isn't a great way to get results in a nice form.
PROC TABULATE is probably easier to work with for beginners.
/*This code is an example of how to generate a table with
Variable Name, Variable Value, Frequency, Percent, Cumulative Freq and Cum Pct
No macro's are required
Use Proc Freq to generate the list, list variables in a table statement if only specific variables are desired
Use ODS Table to capture the output and then format the output into a printable table.
*/
*Run frequency for tables;
ods table onewayfreqs=temp;
proc freq data=sashelp.class;
table sex age;
run;
*Format output;
data want;
length variable $32. variable_value $50.;
set temp;
Variable=scan(table, 2);
Variable_Value=strip(trim(vvaluex(variable)));
keep variable variable_value frequency percent cum:;
label variable='Variable'
variable_value='Variable Value';
run;
*Display;
proc print data=want(obs=20) label;
run;
See this example that's more specific to PROC FREQ, which isn't a great way to get results in a nice form.
PROC TABULATE is probably easier to work with for beginners.
/*This code is an example of how to generate a table with
Variable Name, Variable Value, Frequency, Percent, Cumulative Freq and Cum Pct
No macro's are required
Use Proc Freq to generate the list, list variables in a table statement if only specific variables are desired
Use ODS Table to capture the output and then format the output into a printable table.
*/
*Run frequency for tables;
ods table onewayfreqs=temp;
proc freq data=sashelp.class;
table sex age;
run;
*Format output;
data want;
length variable $32. variable_value $50.;
set temp;
Variable=scan(table, 2);
Variable_Value=strip(trim(vvaluex(variable)));
keep variable variable_value frequency percent cum:;
label variable='Variable'
variable_value='Variable Value';
run;
*Display;
proc print data=want(obs=20) label;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.