BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
VCucu
Obsidian | Level 7
Hello,
 
i have the following code for writing a report to HTML:
 
"
ods html file='C:\analysis1.html'
newfile=page;
proc report data=sales nowd list headline headskip spacing=2 split='~';
by branchid;
column (branchid representative sales);
define branchid / group noprint;
define representative / display 'Representative Name';
define Sales / display f=comma20. 'Yearly Sales';
run;
ods html close;
"
This creates for each change of branch ID in the report an incremental file e.g.:
analysis1.html
analysis2.html
analysis3.html
...
 
Is there any way to change the name of the output html file for each page dynamically? i would like to have a combination of 'analysis1' || trim(branchid) ||'.html' variable, resulting in
analysis1HK.html           (Hong Kong Branch)
analysis1LO.html           (London Branch)
....
and so on for all branchid defined in the report.
 
Is this possible somehow ?
 
Thank you very much,
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Unfortunately not at this point. One option is to add a rename step to the file, but you need to do it after you have the ODS CLOSE statement so the file is created and finalized.
https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p14axci3mo3egan1okbcydvbt433.htm...

Another option, one I usually use, is to use a macro instead and explicitly control the output name.
https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

View solution in original post

2 REPLIES 2
Reeza
Super User
Unfortunately not at this point. One option is to add a rename step to the file, but you need to do it after you have the ODS CLOSE statement so the file is created and finalized.
https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p14axci3mo3egan1okbcydvbt433.htm...

Another option, one I usually use, is to use a macro instead and explicitly control the output name.
https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md
VCucu
Obsidian | Level 7
super. thank you very much for the feedback. 🙂 i will try the macro variant.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 420 views
  • 1 like
  • 2 in conversation