BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wlierman
Lapis Lazuli | Level 10

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

https://gist.github.com/statgeek/e0903d269d4a71316a4e

View solution in original post

4 REPLIES 4
Reeza
Super User
Did you read the blog post I linked to in your other question? It shows you how to find the specific table names either using ODS TRACE or the DETAILS section in the documentation for that specific procedure.
wlierman
Lapis Lazuli | Level 10
Yes I did download the link.  Ron Cody is one of my favorite SAS authors.


Reeza
Super User

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;

https://gist.github.com/statgeek/e0903d269d4a71316a4e

wlierman
Lapis Lazuli | Level 10
Thank you. I think that ODS Table sounds promising.

Thanks for the link to more information.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 964 views
  • 1 like
  • 2 in conversation