BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
WilliamB
Obsidian | Level 7

Hello,

I would like to keep that individuals who have 211 in the name variable.

Example

211BWBC I want to keep

210ECFP I delete


But I would not like to create new columns by separating the variable name.


I would like to use the scan function.

Thanks for your help.

 

 


data table;
input Note Name $;
cards;
8.3860559819623 210WEAO
15.5453663184726 211BWBC
17.6964655703656 210ECFP
13.1571255262187 211PKKJ
9.68736898002401 211HVHQ
10.6813100977326 211POMB
10.550264669724 211ZNQQ
0.0137936072989309 210AMJL
12.1139082894838 209XBZI
9.61956573832501 211LPJF
16.6234269133052 211WVEI
3.97311995569568 210JTFB
15.3252688167527 211TIIF
12.1379157216451 211KQLL
0.340648291882129 211DGMD
0.580565770662087 209QZTW
13.7217455692869 211ODHO
14.5722830026303 211XQJC
4.80396668369969 211ISBM
2.35396936861499 210KBGQ
7.50175770970474 211KGHH
6.14469376072229 209CXSG
11.977944705167 210TSHR
15.0357006553603 209YYNH
17.2611601306417 211QTUA
12.89070855245 210ZZXT
16.9492553096389 210NVEQ
8.17649698621122 211YOSP
18.0045428790637 211YYUO
14.9754022888188 211BYNS
3.0461865950108 211RNCD
12.957558565645 210LOBX


;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Damo
SAS Employee

Hi @WilliamB

 

The SCAN() function might not be what you need.

Many options exist, one with INDEX() as a boolean.

 

data result;
set table;
if index(upcase(name),'211');
run;

Hope that helps.

 

Cheers,
Damo

View solution in original post

5 REPLIES 5
Satish_Parida
Lapis Lazuli | Level 10
data table;
input Note Name $;
if findw(Name,'211')>0 then output;	*findw function;
else delete;
cards;
8.3860559819623 210WEAO
15.5453663184726 211BWBC
17.6964655703656 210ECFP
13.1571255262187 211PKKJ
9.68736898002401 211HVHQ
10.6813100977326 211POMB
10.550264669724 211ZNQQ
0.0137936072989309 210AMJL
12.1139082894838 209XBZI
9.61956573832501 211LPJF
16.6234269133052 211WVEI
3.97311995569568 210JTFB
15.3252688167527 211TIIF
12.1379157216451 211KQLL
0.340648291882129 211DGMD
0.580565770662087 209QZTW
13.7217455692869 211ODHO
14.5722830026303 211XQJC
4.80396668369969 211ISBM
2.35396936861499 210KBGQ
7.50175770970474 211KGHH
6.14469376072229 209CXSG
11.977944705167 210TSHR
15.0357006553603 209YYNH
17.2611601306417 211QTUA
12.89070855245 210ZZXT
16.9492553096389 210NVEQ
8.17649698621122 211YOSP
18.0045428790637 211YYUO
14.9754022888188 211BYNS
3.0461865950108 211RNCD
12.957558565645 210LOBX
;
run;
WilliamB
Obsidian | Level 7

Thank you for your help but it does not work

Damo
SAS Employee

Hi @WilliamB

 

The SCAN() function might not be what you need.

Many options exist, one with INDEX() as a boolean.

 

data result;
set table;
if index(upcase(name),'211');
run;

Hope that helps.

 

Cheers,
Damo

WilliamB
Obsidian | Level 7

Thank you for your help. 🙂

srinath3111
Quartz | Level 8
data result;
set table;
where name like ('211%');
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1346 views
  • 2 likes
  • 4 in conversation