BookmarkSubscribeRSS Feed
Sikcion
Fluorite | Level 6

Hi! guys! I have a question about SAS Macro:

截屏2023-08-01 下午8.29.03.png

截屏2023-08-01 下午8.29.42.png截屏2023-08-01 下午8.29.47.png

I've written the code below:

data Profile1;
set Profile;
Age = intck("year", Birthday, today());
run;


%macro profile1(title,state,age,year,Total_balance);
proc report data=Profile1 nowd colwidth=10 spacing=5 headline headskip;
column Acct_ID Name Age Balance Last_Tran_Date;
define Last_Tran_Date / format = ddmmyy10.;
compute before _page_ / style={just=left};
line @1 "Title: &title" @50 "Run Date: &sysdate";
line @1 "State:" &state @40 "Age: >= &age" @62 "Tran Year: &year";
line " ";
endcomp;
%if &Total_balance = on %then %do;
compute after /style={just=left} ;
line 60* " ";
line @1 "Total Balance:" @38 balance.sum dollar12.;
endcomp;
%end;
where Age >= &age and state in (&state) and year(Last_Tran_Date)= &year;

%mend;
%profile1(title= Detail Listing Of Account,state =%str("NY"),age=40,year=2016,Total_balance=on);

 

The question is:
If I only input single state such as "NY", I can run this program successfully, but i can't call multiple states; such as: %profile1(title= Detail Listing Of Account,state =%str("NY, CA"),age=40,year=2016,Total_balance=on);

Can you help me to fix this problem? Thank you!!

1 REPLY 1
andreas_lds
Jade | Level 19

Just specify the states as shown in the task description: %str("NY", "CA").

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 298 views
  • 0 likes
  • 2 in conversation