4
votes

I am using sas eg and set the output as html format. So everytime I run proc freq (or other similar procs), the output is put to html. I want to write some code, either in sas language or macro, that automatically save the output to files. Anyone knows how to do it? Many thanks.

1

1 Answers

7
votes

It's not clear from your question whether you want to...

...Save a file created in EG as part of a process flow: You can right-click your html output in the EG process designer, and choose Export > Export [OutputFile] As A Step In Project from the context menu, and then specify the path and name of the file you want to save. This way, an Export File task will be created in your process flow, which will save the output where you want each time you run the flow.

...Send html output to a file as part of your code: If you're writing code in your EG task, use the Output Delivery System (ODS), simply by opening the relevant ODS destination before the step(s) of your code that you want output, and closing it again afterwards like this:

ods html file="C:\Path\To\MyFile.html";

* --Your proc freq code here-- ;

ods html close;

There's plenty to know about ODS if you want total control over your output, but this will get you started. There's no need for macro code to achieve saving output to a file.

...Save the data file created by the FREQ procedure: If you actually want a SAS data file that contains the frequencies you're seeing in your html output, you can add the out= option on the proc freq tables statement like this:

proc freq data=sashelp.shoes;
  tables Region / out=myLib.MyFreqs outcum ;
run;

where myLib points to a particular path you want the dataset saved to. Note that many other SAS procedures have similar options to output a dataset with their results for further manipulation.

Do any of the above cover what you want to do?