Hi! guys! I have a question about SAS Macro:
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!!
Just specify the states as shown in the task description: %str("NY", "CA").
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.