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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 625 views
  • 1 like
  • 3 in conversation