BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
stodo53
Fluorite | Level 6

Hi all,

 

I have been trying to use a macro to print out multiple pdfs so that each center has their own pdf. We need each center to have their own pdf document. I don't think I can use the "newfile=bygroup" option in ODS because I also need it to print out by patient ID number... and also I would prefer to be able to name each pdf document by the center name. 

 

The code I currently have prints out separate pdfs with the center names, however, they all look identical, as such, I know I didn't successfully separate the pdf print outs by the center type. 

 

Any help would be greatly appreciated.

%MACRO printbycenter (centercodes);
ods pdf file="...\extreme_centers_&centercodes..pdf";
PROC PRINT DATA= new;
WHERE PATID_NUM IN (1332, 2198, 2332) AND (heightsds_r NE .) AND (heightsds_r < -6 OR heightsds_r > 6) |
      PATID_NUM IN (238, 327, 599, 917, 1030, 1241, 1395, 1650, 1679, 2111, 2197, 2393, 2708) AND (weightsds_r NE .) AND (weightsds_r < -6 OR weightsds_r > 6)|
	  PATID_NUM IN (1030, 1961, 2111) AND (bmisds_r NE .) AND (bmisds_r < -6 OR bmisds_r > 6)|
	  PATID_NUM IN (1332, 2198) AND (syssds_04 NE .) AND (syssds_04 < -6 OR syssds_04 > 6)|
	  PATID_NUM IN (1332, 2198) AND (diasds_04 NE .) AND (diasds_04 < -6 OR diasds_04> 6)|
	  PATID_NUM IN (116, 148, 303, 385, 560, 969, 2243, 2412) AND (lvmi_devereux NE .) AND (lvmi_devereux < 5 OR lvmi_devereux > 200)|
      PATID_NUM IN (116, 148, 303, 385, 560, 969, 2243, 2412) AND (lvmi_chinali NE .) AND (lvmi_chinali < 5 OR lvmi_chinali > 200)|
	  PATID_NUM IN (164,492,629,679,746,797,806,828,834,846,873,874,965,1150,1193,1507,1548,1564,1578,1619,1644,1752,1765,1930,1934,1942,1988,2108,2117,
 					2128,2258,2269,2284,2351,2419,2513,2682,2699) AND (egfr_schwartz NE .) AND (egfr_schwartz>160);
BY patid;
VAR patid birthmonthyear RTx_Date vdate age ageattx timesincetx sex egfr_schwartz crea_mgdl height heightsds_r BMI_r bmisds_r; *list all relevant variables;
RUN;
ODS PDF CLOSE;
%MEND;
%printbycenter (DE_Hannover); 
%printbycenter (DE_Leipzig); 
%printbycenter (DE_Frankfurt § DE_Heidelberg); 
%printbycenter (TR_Adana); 
%printbycenter (TR_Hacettepe);
%printbycenter (DE_Hamburg); 
%printbycenter (UK_Manchester); 
%printbycenter (IT_Padua);
%printbycenter (DE_Bonn § DE_Bonn_KNZ); 
%printbycenter (IT_Rome); 
%printbycenter (DE_Bonn); 
%printbycenter (PL_Warsaw); 
%printbycenter (DE_Cologne); 
%printbycenter (RU_Moscow); 
%printbycenter (DE_Tuebingen); 
%printbycenter (UK_Nottingham); 
%printbycenter (TR_Istanbul); 
%printbycenter (FR_Lyon);
%printbycenter (IE_Dublin); 
%printbycenter (IT_Turin); 
%printbycenter (IT_Milan); 
%printbycenter (ES_Barcelona);
%printbycenter (DE_Essen); 
%printbycenter (UK_Birmingham); 
%printbycenter (DE_Hamburg § DE_Munich);
%printbycenter (DE_Marburg);
%printbycenter (DE_Heidelberg); 
%printbycenter (DE_Cologne § DE_Heidelberg); 
%printbycenter (FR_Toulouse); 
%printbycenter (SI_Ljubljana);
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Macro triggers do not resolve when enclosed in single quotes.

Mammoth-sized hint: always use double quotes in SAS, unless explicitly needed (masking triggers contained in the strings, or double quotes).

View solution in original post

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

Why isn't centercodesused in your where clause?

 

stodo53
Fluorite | Level 6

I tried the following but then it says I have no observations and so nothing is printed out, which makes no sense. If I leave the quotations out of &centercodes then I get an error. 

%MACRO printbycenter (centercodes);
ods pdf file="...\extreme_centers_&centercodes..pdf";
PROC PRINT DATA= new;
WHERE centercodes in ('&centercodes') &  (PATID_NUM IN (1332, 2198, 2332) AND (heightsds_r NE .) AND (heightsds_r < -6 OR heightsds_r > 6) |
      PATID_NUM IN (238, 327, 599, 917, 1030, 1241, 1395, 1650, 1679, 2111, 2197, 2393, 2708) AND (weightsds_r NE .) AND (weightsds_r < -6 OR weightsds_r > 6)|
	  PATID_NUM IN (1030, 1961, 2111) AND (bmisds_r NE .) AND (bmisds_r < -6 OR bmisds_r > 6)|
	  PATID_NUM IN (1332, 2198) AND (syssds_04 NE .) AND (syssds_04 < -6 OR syssds_04 > 6)|
	  PATID_NUM IN (1332, 2198) AND (diasds_04 NE .) AND (diasds_04 < -6 OR diasds_04> 6)|
	  PATID_NUM IN (116, 148, 303, 385, 560, 969, 2243, 2412) AND (lvmi_devereux NE .) AND (lvmi_devereux < 5 OR lvmi_devereux > 200)|
      PATID_NUM IN (116, 148, 303, 385, 560, 969, 2243, 2412) AND (lvmi_chinali NE .) AND (lvmi_chinali < 5 OR lvmi_chinali > 200)|
	  PATID_NUM IN (164,492,629,679,746,797,806,828,834,846,873,874,965,1150,1193,1507,1548,1564,1578,1619,1644,1752,1765,1930,1934,1942,1988,2108,2117,
 					2128,2258,2269,2284,2351,2419,2513,2682,2699) AND (egfr_schwartz NE .) AND (egfr_schwartz>160));
BY patid;
VAR patid birthmonthyear RTx_Date vdate age ageattx timesincetx egfr_schwartz crea_mgdl height heightsds_r BMI_r bmisds_r; *list all relevant variables;
RUN;
ODS PDF CLOSE;
%MEND;
%printbycenter (DE_Hannover); 
%printbycenter (DE_Leipzig); 
%printbycenter (DE_Frankfurt § DE_Heidelberg); 
%printbycenter (TR_Adana); 
%printbycenter (TR_Hacettepe);
%printbycenter (DE_Hamburg); 
%printbycenter (UK_Manchester); 
%printbycenter (IT_Padua);
%printbycenter (DE_Bonn § DE_Bonn_KNZ); 
%printbycenter (IT_Rome); 
%printbycenter (DE_Bonn); 
%printbycenter (PL_Warsaw); 
%printbycenter (DE_Cologne); 
%printbycenter (RU_Moscow); 
%printbycenter (DE_Tuebingen); 
%printbycenter (UK_Nottingham); 
%printbycenter (TR_Istanbul); 
%printbycenter (FR_Lyon);
%printbycenter (IE_Dublin); 
%printbycenter (IT_Turin); 
%printbycenter (IT_Milan); 
%printbycenter (ES_Barcelona);
%printbycenter (DE_Essen); 
%printbycenter (UK_Birmingham); 
%printbycenter (DE_Hamburg § DE_Munich);
%printbycenter (DE_Marburg);
%printbycenter (DE_Heidelberg); 
%printbycenter (DE_Cologne § DE_Heidelberg); 
%printbycenter (FR_Toulouse); 
%printbycenter (SI_Ljubljana); 


Kurt_Bremser
Super User

Macro triggers do not resolve when enclosed in single quotes.

Mammoth-sized hint: always use double quotes in SAS, unless explicitly needed (masking triggers contained in the strings, or double quotes).

stodo53
Fluorite | Level 6

This worked! Thank you very much, and I also appreciate the other tip you left in the second comment - I corrected my code accordingly. 

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
  • 5 replies
  • 478 views
  • 2 likes
  • 3 in conversation