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

Hello,

 

I am working within proc report and have a macro that sends out the output depending on which group I call.  Each group has different column headers, however I have 5 groups that have the same headers.

 

For  example (portion of code):

 

%if &nbr. =1 %then %do;

 

ods listing close;
ods tagsets.rtf file = "&&outpath&nbr" &repopt;
title3 "&&ttlnum&nbr";
title4 "&ttldesc";
title5 "&&ttlpop&nbr";
title6 "Part 1 of 2";


proc report data = final&pop headline headskip nowindows missing split = "@"
style = [protectspecialchars = off] style(report) = [bordertopwidth = 1.5] spanrows;
columns brk ptord aedecod text _1 ("Bupivacaine HCl &ulspan" _2 _3 _4 _98) sp ("HTX-011 &ulspan" _99);

 

....

%end;

 

I there a way to change 

%if &nbr. =1 %then %do.....to something like this>

 %if &nbr. in (1 2 3 4 5)  %then %do  ((OF COURSE THIS NOT WORKING)) 

 

 

 

So when I call macro

example:  %rept (1,POP1);%rept (2,POP2); %rept (3,POP3);%rept (4,POP4);%rept (5,POP5)...they will all use all use the same report columns.

 

 

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

You can use OR conditions in macro IF statements:

%if &nbr. = 1 %or  &nbr. = 2 %or &nbr. = 3 %or &nbr. = 4 %or &nbr. =  5 %then %do;

 

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

You can use OR conditions in macro IF statements:

%if &nbr. = 1 %or  &nbr. = 2 %or &nbr. = 3 %or &nbr. = 4 %or &nbr. =  5 %then %do;

 

PaigeMiller
Diamond | Level 26

To get your macro version of the IN operator to work, you need to turn on the MINOPERATOR option, and set the MINDELIMITER option to be a space in the %MACRO statement.

 

%macro rept( )/minoperator mindelimiter=' ';

 

--
Paige Miller

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