The SAS Output Delivery System and reporting techniques

Date stamp with SAS

Reply
N/A
Posts: 0

Date stamp with SAS

I am trying to generate date stamps for SAS output files. It's like this: For every output (xls and csv files) that a SAS program generates, I want the output file names to automatically take the current date. Eg. If the program is run on 07-26-2007 then some of the files it will generate will be named 07-26-2007_out.industry.xls, 07-26-2007_out.AAA.xls, etc ... So basically, the suffix remains constant, only the prefix (date ) will change. I guess one can also write a shell scrip for it. Trying to figure that out as well.

Another question: Is there a good way to enhance SAS outputs. I can use ODS, but I want generate a much prettier output. Not sure if ODS can be customized.

Thanks in advance, guys!
Einnor
N/A
Posts: 0

Re: Date stamp with SAS

To generate the dates you might try something like this:
%sysfunc(translate(%sysfunc(date(), mmddyy10.), "-", "/"))

An example using the line above:
data j;
x = 1;
run;

ods html file=
"c:\temp\%sysfunc(translate(%sysfunc(date(), mmddyy10.), "-", "/")).xls"
style=minimal;

proc print data=j;
run;

ods html close;

I am not sure what you mean about enhancing SAS outputs. You will need to be more specific.

Good luck,
Louis
N/A
Posts: 0

Re: Date stamp with SAS

Hey Louis,
Thanks so much for your response. When I say enhancing outputs, I mean making it prettier. Like giving the heading rows a shade, giving the table a frame, etc. I am not looking at anything too sophisticated, just a simple table with a few shades ... basically, something good enough to be presented before business users.

Thanks
SAS Super FREQ
Posts: 8,740

Re: Date stamp with SAS

Hi:
I think you can do a LOT with ODS. It really depends on your destination of choice and WHERE (what application) you're using to render or present the output.

For example, if you are running SAS 8 and you use ODS HTML, the output looks pretty good in Excel and Word with a simple STYLE=SASWEB change to the ODS invocation. However, in SAS 9, with the move to HTML 4.0 compliant tags, Microsoft does not play nice with HTML 4.0 -- Office much prefers either 3.2 compliant HTML tags or --better -- Microsoft HTML tags or Microsoft Spreadsheet XML tags (for Excel).

Sometimes, you have to change the style template to really go down the "pretty" road -- but again, it depends on where your output will ultimately be presented.

With PROC PRINT, PROC REPORT and PROC TABULATE, you have the chance to extensively control the colors and fonts, table attributes, etc. You will find that something that looks great in a browser might need a bit of tweaking to look better in Excel or Word or Acrobat Reader.

This is just something to test out and then open each result file in the application where you finally want to see the results. Starting with Office 97, you could open HTML files with Word and Excel. The MSOFFICE2K file is designed specifically for the kind of HTML used with Office 2000 and higher. And the EXCELXP file is designed specifically for Excel 2002 and higher (earlier versions of Excel will not open the XML). You should start with the ODS result file that looks the best in your viewing application and then start making changes from there.

As you can see, I've done a bit of header changing with PROC REPORT. If I wanted to do that same kind of header changing for the PROC FREQ, I'd have to use a different technique (Style and/or table template).

For more info on how to use ODS and PROC REPORT or ODS and style templates, the Tech Support FAQ on ODS are really, really a good place to start.
http://support.sas.com/rnd/base/topics/templateFAQ/Template.html

cynthia
[pre]
ods html3 file='c:\temp\ht3.html' style=sasweb;
ods html4 file='c:\temp\ht4.html' style=sasweb;
ods msoffice2k file='c:\temp\mso.html' style=sasweb;
ods tagsets.excelxp file='c:\temp\xp.xml' style=sasweb;
ods rtf file='c:\temp\wordproc.rtf' style=sasweb;
ods pdf file='c:\temp\adoberdr.pdf' style=sasweb;

proc report data=sashelp.shoes nowd;
column region product sales;
define region /group
style(header)={background=pink};
define product /group
style(header)={background=yellow foreground=black};
define sales/ sum;
rbreak after /summarize;

proc freq data=sashelp.shoes;
tables subsidiary;
run;
ods _all_ close;
[/pre]
SAS Super FREQ
Posts: 8,740

Re: Date stamp with SAS

Deleted extra post from when browser had a hiccup.
N/A
Posts: 0

Re: Date stamp with SAS

thanks, Cynthia. That was really helpful
N/A
Posts: 0

Re: Date stamp with SAS

Hey Louis,
I want the date in the yyyymmdd format ... would that mean just changing the mmddyy10. to YYMMDDw.?

Thanks
Ask a Question
Discussion stats
  • 6 replies
  • 250 views
  • 0 likes
  • 2 in conversation