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 Experts,

I would like to replace 'CLEFT LIP / CLEFT PALATE / CLEFT PALETTE' with 'UAIRWAY' in the sample dataset 'Have.'   I created a macro list 'Uairway_name.'   I found the macro could not be recognized in the Prxchange command.   Please help me to fix it.  Also, is there any limitation for the text length in the Prxchange?   My real texts need to be replaced are over 500 character long.

 

data Have;
      infile datalines delimiter='/';
  input Disease : $300.  ;
datalines;
	CLEFT PALETTE, ADHD, CHRONIC RHINITIS /
	HAVING A GTUBE, ENCEPHALOMALACIA, HIDRADENITIS, AUTISM/
	ENCEPHALOPATHY, GTUBE SUPPORTIVE, HEP C EXPOSURE /
	AUTISM SPECTRUM, SPEECH & COGNITIVE DELAY, CLEFT LIP
;
run;

data AIRWAY_Name;
  infile datalines dsd;
  input  Name : $50. ;
datalines;
	CLEFT LIP, 
	CLEFT PALATE,
	CLEFT PALETTE
	;
run;

options noquotelenmax;
proc sql;
	select trim(Name) into : Uairway_name separated by '|'  from AIRWAY_Name;
quit;

%put &Uairway_name;

data dataout;
	set Have;
	Disease2 = prxchange('s/[^,]*(&Uairway_name.)[^,]*/UAIRWAY/i',              -1, Disease); 
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Don't add quotes into your strings.  Use double quotes when referencing you macro variable.

The macro processor ignores the strings in single quotes so:

'&mvar'

Is the string &mvar.

While 

"&mvar"

Will replace &MVAR with value of the MVAR macro variable.

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

The macro processor ignores strings bounded by single quotes.  Use double quotes instead.

 

 

PS Why did you indent your in-line data lines?

ybz12003
Rhodochrosite | Level 12

I put double quote in the macro list, still did not work.

 

proc sql;
	select quote(trim(Name)) into : Uairway_name separated by '|'  from AIRWAY_Name;
quit;

%put &Uairway_name;
Tom
Super User Tom
Super User

Don't add quotes into your strings.  Use double quotes when referencing you macro variable.

The macro processor ignores the strings in single quotes so:

'&mvar'

Is the string &mvar.

While 

"&mvar"

Will replace &MVAR with value of the MVAR macro variable.

ybz12003
Rhodochrosite | Level 12
Tom, it's working. Thanks.

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
  • 4 replies
  • 436 views
  • 1 like
  • 2 in conversation