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

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