I've tried no quotes, single quotes, double quotes, etc. but can't get my hcpc macro list to work in the code below. It tells me that there was a Syntax error while parsing WHERE clause.
Please help me fix my code, but also help me understand the general rule and what makes my first list different from my second.
libname hcgout '/CUDM/HCG/HCG_PROD/Data_Sets/Output_NET' ; %let list = linenum memberid memberctg incurd_yr_mo hcpcs; %let hcpc = "E0431", "E1390", "E1392", "K0738"; data hcgTables2014toPresent ; set hcgout.outclaims_2014 (where= (hcpcs in &hcpc.) keep=&list.) hcgout.outclaims_2015 (where= (hcpcs in &hcpc.) keep=&list.) hcgout.outclaims_prior (where= (hcpcs in &hcpc.) keep=&list.) hcgout.outclaims_current (where= (hcpcs in &hcpc.) keep=&list.); run;
I would suggest dropping the commas in the list as well. The IN operator no longer requires comma separated values and there are places where commas in a macro variable, such as passing as a parameter in macro code, will cause things to break.
Also I would suggest that since IN requires the parentheses that code attempting to use the macro list should look like:
where= (hcpcs in ( &hcpc. ) )
instead of placing the () in the macro value.
You need brackets around your list of hcpc
libname hcgout '/CUDM/HCG/HCG_PROD/Data_Sets/Output_NET' ;
%let list = linenum memberid memberctg incurd_yr_mo hcpcs;
%let hcpc = ("E0431", "E1390", "E1392", "K0738");
data hcgTables2014toPresent ;
set hcgout.outclaims_2014 (where= (hcpcs in &hcpc.) keep=&list.)
hcgout.outclaims_2015 (where= (hcpcs in &hcpc.) keep=&list.)
hcgout.outclaims_prior (where= (hcpcs in &hcpc.) keep=&list.)
hcgout.outclaims_current (where= (hcpcs in &hcpc.) keep=&list.);
run;
Always run the code without any macro language, and then replace values with macro variables.
As it is, your syntax for the in() statement is invalid, so there is not chance of anything running.
Once the syntax of hard-coded values is right, you can think about soft-coding with the macro language.
I would suggest dropping the commas in the list as well. The IN operator no longer requires comma separated values and there are places where commas in a macro variable, such as passing as a parameter in macro code, will cause things to break.
Also I would suggest that since IN requires the parentheses that code attempting to use the macro list should look like:
where= (hcpcs in ( &hcpc. ) )
instead of placing the () in the macro value.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.