BookmarkSubscribeRSS Feed
raivester
Quartz | Level 8

This seems like something I should easily be able to find the answer to, but, alas, I'm having trouble. I'm reading in a data set and then running a proc contents and a proc freq command. I would like to save the tables that are output to the Results Viewer to a folder on my local machine. Can someone explain how to do this?

 

proc import datafile="filepath\filename.dta" out=mydata dbms = dta replace;
run;

proc contents; 
run;

proc freq data=mydata; table var1; 
run;
2 REPLIES 2
Reeza
Super User

1. Save to a data set and then export that data set. The table layout is not as shown in the Results pane.

2. Pipe results directly to a PDF, Word or Excel file. Results are more similar to the ones shown in the Results pane.

 

/*1*/
proc freq data=sashelp.heart;
table chol_status / out= want1;
run;

proc print data=want1;
run;

*export to data set;
proc export data=want1 outfile='/folders/myfolders/procfreqout.xlsx'
dbms=xlsx replace; run;

/*2*/

ods excel file = '/folders/myfolders/procfreqoutput2.xlsx' style = meadow;

proc freq data=sashelp.heart;
table chol_status / out= want1;
run;

ods excel close;

ods pdf file = '/folders/myfolders/procfreqoutput2.pdf' style = meadow;

proc freq data=sashelp.heart;
table chol_status / out= want1;
run;

ods pdf close;

@raivester wrote:

This seems like something I should easily be able to find the answer to, but, alas, I'm having trouble. I'm reading in a data set and then running a proc contents and a proc freq command. I would like to save the tables that are output to the Results Viewer to a folder on my local machine. Can someone explain how to do this?

 

proc import datafile="filepath\filename.dta" out=mydata dbms = dta replace;
run;

proc contents; 
run;

proc freq data=mydata; table var1; 
run;

 

Rick_SAS
SAS Super FREQ

It is not clear what format you want for the tables. If you want to save the results as a SAS data set, you can use the ODS OUTPUT statement and save the data set to a libref that points to a directory on your PC.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 6887 views
  • 0 likes
  • 3 in conversation