BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Banana19
Obsidian | Level 7

Hi All,

I have a table with different columns like columnA,.....columnN. I need to generate pdf report based on every unique variable present in the columnA and columnA has more than 1500 unique variables.

Ex:-

ColumnA.        ColumnB ......... ColumnN

001abc1234.    ....

001abc1234.    ....

001def1234.    ....

001def1234     ....

001abc5678.   ....

001abc 5678.   ....

In my code i'm currently able to generate pdf for 1 unique variable at a time and it is not possible to generate PDF reports more than 1500 times manually. I'm wondering how to automate the process so that in future irrespective of the count of unique variables i need to generate pdf reports for all of them.

It would be great if anyone could help me with this issue.

 

Thanks,

RD

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

It depends on how complex the report code is. It could be as simple as using the NEWFILE option on the ODS PDF statement or refactoring your code to be a macro that you can call dynamically using CALL EXECUTE.

ODS PDF NEWFILE option is here - note that you cannot easily control the file name which may be an issue.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/odsug/n0mc4eolqoned0n16oy88mpj0e4g.htm#p0sdu2...

Otherwise here's a tutorial on turning your reporting code into macro code that can be automated. I highly suggest working through the example fully and then doing it on your own data.
https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

 


@Banana19 wrote:

Hi All,

I have a table with different columns like columnA,.....columnN. I need to generate pdf report based on every unique variable present in the columnA and columnA has more than 1500 unique variables.

Ex:-

ColumnA.        ColumnB ......... ColumnN

001abc1234.    ....

001abc1234.    ....

001def1234.    ....

001def1234     ....

001abc5678.   ....

001abc 5678.   ....

In my code i'm currently able to generate pdf for 1 unique variable at a time and it is not possible to generate PDF reports more than 1500 times manually. I'm wondering how to automate the process so that in future irrespective of the count of unique variables i need to generate pdf reports for all of them.

It would be great if anyone could help me with this issue.

 

Thanks,

RD

 


 

View solution in original post

4 REPLIES 4
Reeza
Super User

It depends on how complex the report code is. It could be as simple as using the NEWFILE option on the ODS PDF statement or refactoring your code to be a macro that you can call dynamically using CALL EXECUTE.

ODS PDF NEWFILE option is here - note that you cannot easily control the file name which may be an issue.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/odsug/n0mc4eolqoned0n16oy88mpj0e4g.htm#p0sdu2...

Otherwise here's a tutorial on turning your reporting code into macro code that can be automated. I highly suggest working through the example fully and then doing it on your own data.
https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

 


@Banana19 wrote:

Hi All,

I have a table with different columns like columnA,.....columnN. I need to generate pdf report based on every unique variable present in the columnA and columnA has more than 1500 unique variables.

Ex:-

ColumnA.        ColumnB ......... ColumnN

001abc1234.    ....

001abc1234.    ....

001def1234.    ....

001def1234     ....

001abc5678.   ....

001abc 5678.   ....

In my code i'm currently able to generate pdf for 1 unique variable at a time and it is not possible to generate PDF reports more than 1500 times manually. I'm wondering how to automate the process so that in future irrespective of the count of unique variables i need to generate pdf reports for all of them.

It would be great if anyone could help me with this issue.

 

Thanks,

RD

 


 

Banana19
Obsidian | Level 7

Thank you Reeza. The second solution you've mentioned is closer to what I expected.

andreas_lds
Jade | Level 19

The easiest way seems to sort the data by ColumnA and use "newfile=bygroup" in the ods pdf statement along with "by ColumnA" in proc report. Unfortunately you can't use #byval1 to name the files.If xcmd is active, renaming the files using os-command is not that difficult, https://communities.sas.com/t5/SAS-Procedures/Rename-External-File/td-p/10703 shows the code, which needs some tweaking, of course.

Banana19
Obsidian | Level 7

Thank you Andreas_ids.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 4 replies
  • 514 views
  • 1 like
  • 3 in conversation