BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

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;
5 REPLIES 5
PaigeMiller
Diamond | Level 26

What is wrong with the code you show? Please explain.

--
Paige Miller
BrahmanandaRao
Lapis Lazuli | Level 10

I  didn't get required output

Required output

South Africa

England

Albany

PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
BrahmanandaRao
Lapis Lazuli | Level 10
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;
donricardo
SAS Employee

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';

donricardo_1-1699388435662.png

 

 

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 2172 views
  • 1 like
  • 3 in conversation