Hi experts,
Here I want to extract S ,E ,y letters contains team
for example output
South Africa
Egland
Albany
data dsn;
input team $ 20.;
datalines;
India
India
Australia
South Africa
England
Albany
;
run;
data want;
set dsn;
where team like 'S%' and 'E%' or '_y';
run;
What is wrong with the code you show? Please explain.
I didn't get required output
Required output
South Africa
England
Albany
Please think about this for a minute.
Can a team's name be like 'S%' and also be like 'E%'?
Yes or no? If no, then what is the proper logic, in words, to get the desired result?
Its works
data want;
set dsn;
where team like 'S%' or team like 'E%' or team like '%y%';
proc print noobs;
run;
proc sql;
select team from dsn
where team like 'S%' or team like 'E%' or team like '%y%';
run;
Change your code to this and it'll do the trick for you. Remember, you must fully specify both the variable (team) and the wildcard expression for each value.
data want;
set dsn;
where team like 'S%' or team like 'E%' or team like '%y';
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.