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.
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.
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
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.