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;
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.
The macro processor ignores strings bounded by single quotes. Use double quotes instead.
PS Why did you indent your in-line data lines?
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;
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.
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.
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.
Ready to level-up your skills? Choose your own adventure.