<?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 How to select observations of specified length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-observations-of-specified-length/m-p/458733#M116438</link>
    <description>&lt;P&gt;I have a large data set with a column called ‘identifier.’ About 90% of cases include a 7 digit ID in the identifier column. For the remaining 10% of cases, however, there wasn’t a 7 digit ID available, so the person who created the data set made up her own faux ID by concatenating address and zip code. I need to split out the “true” IDs so I can use them to merge with another file. I want to leave the ‘identifier’ column as is, since the faux IDs may be helpful in some circumstances, but create a new numeric column called ID that only includes the 7 digit ID numbers (and leaves the rest blank). I’m very new to SAS, so I’m sure there’s a simple solution but I just don’t know it! I’ve tried using trim and subst commands but I just can’t get this to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example of the data I have to work with (the final column is the result I’m looking for):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Identifier&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;address&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zip&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1234567&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 240 Main Ave.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 44230&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1234567&lt;/P&gt;&lt;P&gt;7654321&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 800 Elm St.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 43240&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7654321&lt;/P&gt;&lt;P&gt;211980thSt43215&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22119 80th St.&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 43215&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help you can give.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Susan&lt;/P&gt;</description>
    <pubDate>Mon, 30 Apr 2018 16:24:01 GMT</pubDate>
    <dc:creator>Susan17</dc:creator>
    <dc:date>2018-04-30T16:24:01Z</dc:date>
    <item>
      <title>How to select observations of specified length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-observations-of-specified-length/m-p/458733#M116438</link>
      <description>&lt;P&gt;I have a large data set with a column called ‘identifier.’ About 90% of cases include a 7 digit ID in the identifier column. For the remaining 10% of cases, however, there wasn’t a 7 digit ID available, so the person who created the data set made up her own faux ID by concatenating address and zip code. I need to split out the “true” IDs so I can use them to merge with another file. I want to leave the ‘identifier’ column as is, since the faux IDs may be helpful in some circumstances, but create a new numeric column called ID that only includes the 7 digit ID numbers (and leaves the rest blank). I’m very new to SAS, so I’m sure there’s a simple solution but I just don’t know it! I’ve tried using trim and subst commands but I just can’t get this to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example of the data I have to work with (the final column is the result I’m looking for):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Identifier&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;address&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zip&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1234567&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 240 Main Ave.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 44230&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1234567&lt;/P&gt;&lt;P&gt;7654321&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 800 Elm St.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 43240&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7654321&lt;/P&gt;&lt;P&gt;211980thSt43215&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22119 80th St.&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 43215&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help you can give.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Susan&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 16:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-observations-of-specified-length/m-p/458733#M116438</guid>
      <dc:creator>Susan17</dc:creator>
      <dc:date>2018-04-30T16:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to select observations of specified length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-observations-of-specified-length/m-p/458735#M116439</link>
      <description>&lt;P&gt;if length(&lt;STRONG&gt;Identifier&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;)=7 then id=&lt;STRONG&gt;Identifier&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or safe bet--&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if length(identifier)=7 and anyalpha(identifier)=0 then id=identifier;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if length(identifier)=7 and anyalpha(identifier)=0 then id=identifier;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 16:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-observations-of-specified-length/m-p/458735#M116439</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-30T16:38:54Z</dc:date>
    </item>
  </channel>
</rss>

