DATA Step, Macro, Functions and more

Find individuals

Accepted Solution Solved
Reply
Contributor
Posts: 33
Accepted Solution

Find individuals

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;

 


Accepted Solutions
Solution
‎01-31-2018 04:09 AM
SAS Employee
Posts: 199

Re: Find individuals

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


All Replies
Frequent Contributor
Posts: 109

Re: Find individuals

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;
Contributor
Posts: 33

Re: Find individuals

Posted in reply to Satish_Parida

Thank you for your help but it does not work

Solution
‎01-31-2018 04:09 AM
SAS Employee
Posts: 199

Re: Find individuals

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

Contributor
Posts: 33

Re: Find individuals

Thank you for your help. Smiley Happy

Contributor
Posts: 37

Re: Find individuals

data result;
set table;
where name like ('211%');
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 142 views
  • 2 likes
  • 4 in conversation