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;
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;
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.