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';
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.