<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating a subset by selecting a specific character string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-by-selecting-a-specific-character-string/m-p/393440#M94740</link>
    <description>&lt;P&gt;Keep an eye on the length of your character variable 'name', like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input name $20.;
   datalines;
Will, Smith
Diana, Ross
Diane, Keaton
Sally, Field
Willy, Thomas
David, Platt
Ana, Smith
;

data test;
set test;
      where name contains 'Smith';
run;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Sep 2017 06:45:06 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2017-09-06T06:45:06Z</dc:date>
    <item>
      <title>Creating a subset by selecting a specific character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-by-selecting-a-specific-character-string/m-p/393433#M94735</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new using SAS, so probably this is a simple question, but I am stuck. I need to create a subset of a file by selecting observations for a specific name that contains a specific character string, let's say 'Smith'. for example, the data is like this:&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input name $;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;Will, Smith&lt;BR /&gt;Diana, Ross&lt;BR /&gt;Diane, Keaton&lt;BR /&gt;Sally, Field&lt;BR /&gt;Willy, Thomas&lt;BR /&gt;David, Platt&lt;BR /&gt;Ana, Smith&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is like this:&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;set test;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; where name contains 'Smith';&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code works properly for names, like 'David', but I am interested in&amp;nbsp; last names, like Smith. Unfortunately it is not working for last names.&lt;/P&gt;&lt;P&gt;Any advice is welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 05:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-by-selecting-a-specific-character-string/m-p/393433#M94735</guid>
      <dc:creator>FoxMulder</dc:creator>
      <dc:date>2017-09-06T05:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subset by selecting a specific character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-by-selecting-a-specific-character-string/m-p/393439#M94739</link>
      <description>&lt;P&gt;You have to rectify your input statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input name $ 1-30;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Sep 2017 06:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-by-selecting-a-specific-character-string/m-p/393439#M94739</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2017-09-06T06:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subset by selecting a specific character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-by-selecting-a-specific-character-string/m-p/393440#M94740</link>
      <description>&lt;P&gt;Keep an eye on the length of your character variable 'name', like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input name $20.;
   datalines;
Will, Smith
Diana, Ross
Diane, Keaton
Sally, Field
Willy, Thomas
David, Platt
Ana, Smith
;

data test;
set test;
      where name contains 'Smith';
run;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Sep 2017 06:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-by-selecting-a-specific-character-string/m-p/393440#M94740</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-09-06T06:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subset by selecting a specific character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-by-selecting-a-specific-character-string/m-p/393564#M94806</link>
      <description>&lt;PRE&gt;
SCAN() can pick up the last name.

if scan(name,-1)='Smith' then ...............


&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Sep 2017 14:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-by-selecting-a-specific-character-string/m-p/393564#M94806</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-09-06T14:02:28Z</dc:date>
    </item>
  </channel>
</rss>

