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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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