<?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: How can I code for a uniform string length where there is variation in data entry in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403708#M25904</link>
    <description>Thanks Kurt...this worked great!</description>
    <pubDate>Thu, 12 Oct 2017 21:26:32 GMT</pubDate>
    <dc:creator>gregor1</dc:creator>
    <dc:date>2017-10-12T21:26:32Z</dc:date>
    <item>
      <title>How can I code for a uniform string length where there is variation in data entry</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403368#M25884</link>
      <description>&lt;P&gt;While using EGP 6.1, I am trying to get a common look for each row of a specific column where the data varies in length.&amp;nbsp; The full ID Number has a prefix of "00" then is followed by 9 other digits.&amp;nbsp; However, some people enter the full ID Number while others only enter the last 9 digits.&amp;nbsp; I am trying to just return the last 9 digits but am having trouble finding what function to use.&amp;nbsp; I have been trying to use the SCAN, the SUBPAD, the combination of SUBPAD with REVERSE functions, etc. and am getting nowhere fast.&amp;nbsp; To make matters more difficult, some of the last 9 digits do begin with "00" which I want to include.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of data and what I am getting back (the first column is the ID Number as people have entered (I tried to reverse the order and then do a SUBSTRN with a limit of 9. As you can see, the good data that started with just 9 digits, now only displays 7 digits but shows a length of 9.&amp;nbsp; On the other hand, the numbers too long numbers that showed 11, are now correctly showing just 9 digits.)&amp;nbsp; Any thoughts on the best practice to limit the number of digits to the last 9?&amp;nbsp; Ideally I would like to start from the end of the number and move to the left 9 digits and&amp;nbsp;return only those 9 digits.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID Number&lt;/TD&gt;&lt;TD&gt;Reversed ID Number&lt;/TD&gt;&lt;TD&gt;SUBSTRN ID Number&lt;/TD&gt;&lt;TD&gt;LNGTH of SUBSTRN&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000359260&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 062953000&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 0629530&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;001094641&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 146490100&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 1464901&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;00161892070&lt;/TD&gt;&lt;TD&gt;07029816100&lt;/TD&gt;&lt;TD&gt;070298161&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;001750341&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 143057100&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 1430571&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;001750357&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 753057100&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 7530571&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01000009831&lt;/TD&gt;&lt;TD&gt;13890000010&lt;/TD&gt;&lt;TD&gt;138900000&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01000047161&lt;/TD&gt;&lt;TD&gt;16174000010&lt;/TD&gt;&lt;TD&gt;161740000&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01000053759&lt;/TD&gt;&lt;TD&gt;95735000010&lt;/TD&gt;&lt;TD&gt;957350000&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;016506959&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 959605610&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 9596056&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 11 Oct 2017 21:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403368#M25884</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2017-10-11T21:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I code for a uniform string length where there is variation in data entry</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403378#M25886</link>
      <description>&lt;P&gt;Since you only have 9 digits you could just convert the string to a number and then back to a string using the Z format to make sure it prefixes zeros for the small numbers.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want = put(input(id_number,32.),Z9.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Oct 2017 22:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403378#M25886</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-11T22:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can I code for a uniform string length where there is variation in data entry</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403458#M25888</link>
      <description>&lt;P&gt;How about this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input idnum :$11.;
cards;
000359260
001094641
00161892070
001750341
001750357
01000009831
01000047161
01000053759
016506959
;
run;

data want;
set have;
length new_idnum $9;
new_idnum = substr(put(input(idnum,11.),z11.),3);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note how I presented example data in a data step, so that others (and you!) only need to copy/paste and submit the code to recreate the dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 06:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403458#M25888</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-12T06:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: How can I code for a uniform string length where there is variation in data entry</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403525#M25889</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;That makes sense, except in the full dataset, I have thousands of rows with separate ID Numbers.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 12:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403525#M25889</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2017-10-12T12:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I code for a uniform string length where there is variation in data entry</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403526#M25890</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/91583"&gt;@gregor1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi Kurt,&lt;/P&gt;
&lt;P&gt;That makes sense, except in the full dataset, I have thousands of rows with separate ID Numbers.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And? What works on 10 rows also works on 10 billion rows.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 12:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403526#M25890</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-12T12:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I code for a uniform string length where there is variation in data entry</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403532#M25891</link>
      <description>&lt;P&gt;I get it, so I don't need to enter the individual&amp;nbsp;ID&amp;nbsp; Numbers in the code?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 13:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403532#M25891</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2017-10-12T13:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I code for a uniform string length where there is variation in data entry</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403535#M25893</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/91583"&gt;@gregor1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I get it, so I don't need to enter the individual&amp;nbsp;ID&amp;nbsp; Numbers in the code?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, not at all. That first data step is just creating some example data on the fly from the examples you gave in your initial post. Instead of the cards section, one could also use an infile statement to read from an external file.&lt;/P&gt;
&lt;P&gt;Using a datastep with cards or datalines is the preferred way to present example data here, as it allows easy (and exact) recreation of data by everyone reading the posts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just apply the second data step to your dataset, and adapt the variable names to your needs.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 13:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403535#M25893</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-12T13:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I code for a uniform string length where there is variation in data entry</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403536#M25894</link>
      <description>Great...I will give it a try. Thanks Kurt!</description>
      <pubDate>Thu, 12 Oct 2017 13:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403536#M25894</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2017-10-12T13:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I code for a uniform string length where there is variation in data entry</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403708#M25904</link>
      <description>Thanks Kurt...this worked great!</description>
      <pubDate>Thu, 12 Oct 2017 21:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-code-for-a-uniform-string-length-where-there-is/m-p/403708#M25904</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2017-10-12T21:26:32Z</dc:date>
    </item>
  </channel>
</rss>

