BookmarkSubscribeRSS Feed
cjschlick
Calcite | Level 5

Hello. I need to create multiple pdf's based on an individual variable within my data. As my actual data are considered confidential (peoples income), I thought the sashelp.Baseball dataset could be used as a viable example. In that data set there are statistics for 322 players. For this example, I need to create 322 pdfs as "statistics sheets" so one could be given to each player individually. Is there a way to combine a DO group with an ODS statement to do this for me? Or is there another method that would be better for this? I appreciate the help. 

4 REPLIES 4
Reeza
Super User

Tutorial on converting a working program to a macro

This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it 🙂 https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

 

Write your program to generate your stats and graphs for one player and then automate it using the approach above. You'll see that's pretty much exactly what this tutorial does, except it uses SASHELP.CARS data but if you work through it you should see how do it for your own process. It creates HTML files uniquely but you can easily change the ODS statement to be PDF instead.

ghosh
Barite | Level 11

You do not need  a do loop.  you can use Proc report BY Variable to to output to a new page for each player.

 

Can you show the code to output stats for a single player? From I can suggest how you can modify that print a unique page for each player

Reeza
Super User
You can use BY group processing for only the simplest of cases in my experience, if you need a table and graph for each report By group processing doesn't work. It also doesn't support dynamic naming of files by the group value which are two big missing features IMO. And those are required 99% of the time I've ever had to do most reporting.
ghosh
Barite | Level 11

It does look like a simple report, I don't see the point in in generating unique file names (but it can be possibly done with a gridded ods layout)if he just wants to hand each person their own sheet.

 

Another option is to query for unique names and loop through the list and create a unique file name for each using an an ods layout absolute structure.  I have created complex dashboards using this technique. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 4 replies
  • 1376 views
  • 0 likes
  • 3 in conversation