Hi SAS Users,
I need help with finding multiple like values of proc_Cd's. I tried prxmatch(proc_cd , &procs ) > 0 .It didn twork.
proc_Cd's are coming in data like - ( Ex: 1234|2345|7898)
procs are coming like - Ex: 1234,2345,4567,8903
proc sql;
create table test as
select * from test
where proc_cd like (&procs)
;
Quit;
Thanks,
Ana
LIKE operator does not support multiple values. Use the IN operator instead. (Code simplification hint: the IN operator in SAS does NOT need commas between the values. Spaces will do just fine.)
%let procs=1234 2345 4567 8903;
proc sql;
create table test as
select * from test
where proc_cd in (&procs)
;
quit;
I tried this below small example with hard coded manual entry values , it worked fine. But when i pass the variable names i am getting warning and 0 observations.
Works -
proc sql;
create table total as
select * from test b
where prxmatch("!(1234|2348)!i" , '1234' ,'2346') > 0
;
Quit;
Does not work -
proc sql;
create table total as
select * from test b
where prxmatch("!(proc_cd)!i" , &proc) > 0
;
Quit;
WARNING: Function PRXMATCH requires at most 2 argument(s). The extra one(s) will be ignored.
Hi SASAna,
The below program looks for the values 1234,2345,4567,8903 in the column Code. The first Data Step creates the test data set.
Let me know if I have misunderstood your question.
Thanks
Mary
data new;
input code $;
datalines;
1234
2345
4567
5464
8903
2090
1234
1234
;
run;
%let procs=1234,2345,4567,8903;
data find;
set new;
do i= 1 to 4;
if code=trim(scan("&procs",i,',')) then output;
end;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.
Find more tutorials on the SAS Users YouTube channel.