<?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 Extracting the first non-zero digit from a numeric variable + delete duplicates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345613#M79522</link>
    <description>&lt;P&gt;Here is my code and I attached the output. Some of the data only extracted 3 digits and then randomly switches to extracting 4 digits?&lt;/P&gt;&lt;P&gt;This is the problem i am solving&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Consider only the first 4 character digits of SSN, find the duplicate groups through By-group processing, and create a SAS data set for these observations. Present the screenshot of the partial SAS LOG, showing the number of observations in this subset of data. Show the output for “corrected SSN” variable using PROC PRINT (OBS=8);”.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data hi.question4;&lt;BR /&gt;infile 'C:\Users\larkj\Desktop\STUDENT.DAT';&lt;BR /&gt;input ssn 1-9;&lt;BR /&gt;SSNc = put(ssn,9.);&lt;BR /&gt;drop SSN;&lt;BR /&gt;rename SSNc = SSN;&lt;BR /&gt;SSN_New=substr(SSNc,1,4);&lt;BR /&gt;run;&lt;BR /&gt;proc sort data = hi.question4&lt;BR /&gt;dupout = SSN_New&lt;BR /&gt;nodupkey;&lt;BR /&gt;by SSN_NEW;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=hi.question4;&lt;BR /&gt;run;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13629i50A91337FFF0419D/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="2017-03-29.png" title="2017-03-29.png" /&gt;</description>
    <pubDate>Thu, 30 Mar 2017 02:17:45 GMT</pubDate>
    <dc:creator>larkjr18</dc:creator>
    <dc:date>2017-03-30T02:17:45Z</dc:date>
    <item>
      <title>Extracting the first non-zero digit from a numeric variable + delete duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345613#M79522</link>
      <description>&lt;P&gt;Here is my code and I attached the output. Some of the data only extracted 3 digits and then randomly switches to extracting 4 digits?&lt;/P&gt;&lt;P&gt;This is the problem i am solving&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Consider only the first 4 character digits of SSN, find the duplicate groups through By-group processing, and create a SAS data set for these observations. Present the screenshot of the partial SAS LOG, showing the number of observations in this subset of data. Show the output for “corrected SSN” variable using PROC PRINT (OBS=8);”.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data hi.question4;&lt;BR /&gt;infile 'C:\Users\larkj\Desktop\STUDENT.DAT';&lt;BR /&gt;input ssn 1-9;&lt;BR /&gt;SSNc = put(ssn,9.);&lt;BR /&gt;drop SSN;&lt;BR /&gt;rename SSNc = SSN;&lt;BR /&gt;SSN_New=substr(SSNc,1,4);&lt;BR /&gt;run;&lt;BR /&gt;proc sort data = hi.question4&lt;BR /&gt;dupout = SSN_New&lt;BR /&gt;nodupkey;&lt;BR /&gt;by SSN_NEW;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=hi.question4;&lt;BR /&gt;run;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13629i50A91337FFF0419D/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="2017-03-29.png" title="2017-03-29.png" /&gt;</description>
      <pubDate>Thu, 30 Mar 2017 02:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345613#M79522</guid>
      <dc:creator>larkjr18</dc:creator>
      <dc:date>2017-03-30T02:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting the first non-zero digit from a numeric variable + delete duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345623#M79528</link>
      <description>&lt;P&gt;Your datastep doesn't make sense. Read SSN as a character from start, don't convert it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the subject line doesn't make sense for your question either...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 02:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345623#M79528</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-30T02:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting the first non-zero digit from a numeric variable + delete duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345625#M79530</link>
      <description>&lt;P&gt;That worked great, don't know why I didn't do that before. Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 02:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345625#M79530</guid>
      <dc:creator>larkjr18</dc:creator>
      <dc:date>2017-03-30T02:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting the first non-zero digit from a numeric variable + delete duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345627#M79532</link>
      <description>&lt;P&gt;If you had wanted to keep using the previous code, use Z9 to apply a 9 digit format with leading 0s.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 03:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345627#M79532</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-30T03:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting the first non-zero digit from a numeric variable + delete duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345628#M79533</link>
      <description>&lt;P&gt;You can read the SSN as a character string.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input SSNc $9. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can convert a numeric value to 9 digits with leading zeros using the Z9 format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SSNc = put(ssn,Z9.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can get the first 4 digits of a 9 digit number using arithmetic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;prefix = int(ssn/10000);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can get the first 4 characters of a 9 character string using SUBSTR().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;prefixc = substr(SSNc,1,4);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 03:10:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345628#M79533</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-30T03:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting the first non-zero digit from a numeric variable + delete duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345650#M79544</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/106603"&gt;@larkjr18&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Here is my code and I attached the output. Some of the data only extracted 3 digits and then randomly switches to extracting 4 digits?&lt;/P&gt;
&lt;P&gt;This is the problem i am solving&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Consider only the first 4 character digits of SSN, find the duplicate groups through By-group processing, and create a SAS data set for these observations. Present the screenshot of the partial SAS LOG, showing the number of observations in this subset of data. Show the output for “corrected SSN” variable using PROC PRINT (OBS=8);”.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data hi.question4;&lt;BR /&gt;infile 'C:\Users\larkj\Desktop\STUDENT.DAT';&lt;BR /&gt;input ssn 1-9;&lt;BR /&gt;SSNc = put(ssn,9.);&lt;BR /&gt;drop SSN;&lt;BR /&gt;rename SSNc = SSN;&lt;BR /&gt;SSN_New=substr(SSNc,1,4);&lt;BR /&gt;run;&lt;BR /&gt;proc sort data = hi.question4&lt;BR /&gt;dupout = SSN_New&lt;BR /&gt;nodupkey;&lt;BR /&gt;by SSN_NEW;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=hi.question4;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 05:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-the-first-non-zero-digit-from-a-numeric-variable/m-p/345650#M79544</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-30T05:27:53Z</dc:date>
    </item>
  </channel>
</rss>

