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

 

 

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 778 views
  • 1 like
  • 3 in conversation