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

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; 
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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. 

View solution in original post

4 REPLIES 4
VinitvictorCorr
Quartz | Level 8
please try using %let hcpc = ("E0431", "E1390", "E1392", "K0738"); and let me know if it works, if it dosent, can you please attach the outclaims_2014 data set or at least an example so i could try to work on the solution
34reqrwe
Quartz | Level 8

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; 
ChrisNZ
Tourmaline | Level 20

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.

 

ballardw
Super User

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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 4 replies
  • 1095 views
  • 5 likes
  • 5 in conversation