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

Hello,

 

I created a macro list below.

 

proc sql noprint;
	select trim(State_Abbr) into : Jurisdiction_list separated by '|'  from States;
quit;

%put &Jurisdiction_list;

 

and the result is shown below.

 

AL|AK|AZ|AR|CA|CO|CT|DE|FL|GA

 

Then I run a data step in PRXMATCH,  I found the &Jurisdiction_list. was NOT able to recognize.  Any idea why?

 

data want;
	SET test;
       
       if prxmatch ('/&Jurisdiction_list./i',ID) then TempID=ID;

run;
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Did you miss to enclose the string literal in double quotes "     "

 

prxmatch ("/&Jurisdiction_list./i",ID) 

View solution in original post

5 REPLIES 5
ybz12003
Rhodochrosite | Level 12

But when I hardcode for that list, it worked.  I can't figure out where went wrong from the above codes.

 

data want;
	SET test;
       if prxmatch ('/AL|AK|AZ|AR|CA/i',id) then TempID=id;
run; 
r_behata
Barite | Level 11

use double quotes to enclose your macro variable.

 

24         
25         GOPTIONS ACCESSIBLE;
26         %Let Jurisdiction_list=%str(AL|AK|AZ|AR|CA|CO|CT|DE|FL|GA);
27         
28         data _null_;
29         /*	SET test;*/
30                ID='AK';
31         
32                if prxmatch ("/&Jurisdiction_list./i",ID) then TempID=ID;
33         
34         	   put TempID=;
35         run;

TempID=AK
ed_sas_member
Meteorite | Level 14

Hi @ybz12003 ,

 

The use of single quotes prevents the resolution of the macrovariable, so you need to use double quotes to avoid this.

if prxmatch ("/AL|AK|AZ|AR|CA/I",id) then TempID=id;

All the best,

novinosrin
Tourmaline | Level 20

Did you miss to enclose the string literal in double quotes "     "

 

prxmatch ("/&Jurisdiction_list./i",ID) 
ybz12003
Rhodochrosite | Level 12

Thank you so much.  I didn't know it need to use double quote for the macro list.

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
  • 5 replies
  • 1666 views
  • 3 likes
  • 4 in conversation