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 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 782 views
  • 1 like
  • 2 in conversation