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 recently asked how to move tables or date from the Results window to another destination.  I got a solution from Reeza which involved using ODS as a wrapper

 

ods excel file='/.....' style=meadow;
proc freq data=sashelp.class;
run;
ods excel close; 

This question is just follow-up to this solution. The question is how do I

pipe tables from Results window to data sets where they can be manipulated, combined, exported or saved for further analysis or use.

 

Thanks for this assistance.

 

wklierman

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

For procedures that do not have an out= data set option, or do not allow what you want in the data set you move into the ODS OUTPUT statement. Which specifies the specific table name created by the procedure and you assign a target data set name.

 

Generic looks like

ods output generatedtable = mydatasetname;
Proc whatever data= mydata <other proc options>;
<other proc statements>
;
run;

You can either look up the tables created in the documentation in the details tab for most procedures, which usually has the options needed to create the table.

Or run your code once with

ods trace on;
<your proc goes here>
ods trace off;

The LOG will then show the names of the tables generated. So you could then place them into one or more ODS OUTPUT statement.

 

The datasets generated by ODS output are often in a different structure, with additional variables, than in the older Output statements for most procs.

 

Note that ODS OUTPUT will also allow you to capture the plotted points in the procedures that provide statistical graphs such as created by the Plot statement in Proc Power, most of the regression procedures and such.

View solution in original post

2 REPLIES 2
maguiremq
SAS Super FREQ

Use the OUT = option on PROC FREQ:

 

proc freq
	data = sashelp.class;
		tables sex / out = s_freq;
run;
ballardw
Super User

For procedures that do not have an out= data set option, or do not allow what you want in the data set you move into the ODS OUTPUT statement. Which specifies the specific table name created by the procedure and you assign a target data set name.

 

Generic looks like

ods output generatedtable = mydatasetname;
Proc whatever data= mydata <other proc options>;
<other proc statements>
;
run;

You can either look up the tables created in the documentation in the details tab for most procedures, which usually has the options needed to create the table.

Or run your code once with

ods trace on;
<your proc goes here>
ods trace off;

The LOG will then show the names of the tables generated. So you could then place them into one or more ODS OUTPUT statement.

 

The datasets generated by ODS output are often in a different structure, with additional variables, than in the older Output statements for most procs.

 

Note that ODS OUTPUT will also allow you to capture the plotted points in the procedures that provide statistical graphs such as created by the Plot statement in Proc Power, most of the regression procedures and such.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 373 views
  • 2 likes
  • 3 in conversation