BookmarkSubscribeRSS Feed
RandyStan
Fluorite | Level 6
Dear All:

My code is

proc freq data = have ;
table X*y / norow nocol ;
weight V ;
run;

Can I output the table to CSV  (preferable) or RTF  format.  Also how can I output the results to a SAS data set?

Randy

 

2 REPLIES 2
Reeza
Super User

SAS dataset - use OUT = on the TABLE statement. 

RTF is possible easily. 

Ods rtf body = ‘c:\....\output.rtf’ style = meadow;

Proc freq data = have;
Table x*y / norow nocol OUT=outDataSet;
Weight V;
Run;

Odd rtf close;


Style controls how the output appears. 
https://documentation.sas.com/?docsetId=odsadvug&docsetTarget=p14qidvs5xf7omn14ommvsuhvmzn.htm&docse...

 

ballardw
Super User

@RandyStan wrote:
Dear All:

My code is

proc freq data = have ;
table X*y / norow nocol ;
weight V ;
run;

Can I output the table to CSV  (preferable) or RTF  format.  Also how can I output the results to a SAS data set?

Randy

 


You can send proc output directly to a CSV file using ODS CSVALL such as:

ods csvall file="x:\data\freq.csv";

proc freq data=sashelp.class;
   tables height*weight/norow nocol;
   weight age;
run;

ods csvall close;

However you may get to spend some time working with system options and such to get "pretty" or desired output as CSV is text and things like the procedure title and auxiliary information like the proc freq cell layout information may not be very pretty as created. And it gets worse for many other procedures.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 486 views
  • 1 like
  • 3 in conversation