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.

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
  • 898 views
  • 1 like
  • 2 in conversation