<?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: Edit ID´s in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104542#M21815</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are only two option.&lt;/P&gt;&lt;P&gt;Either the ID´s got 2 or 5 characters. And I need to get the ID´s all to 5 characters. So i want to add three times "0" behind the ID´s with 2 characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable is text.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jul 2012 14:37:53 GMT</pubDate>
    <dc:creator>chofmeister</dc:creator>
    <dc:date>2012-07-11T14:37:53Z</dc:date>
    <item>
      <title>Edit ID´s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104540#M21813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be very nice if somebody help me. I try to add some 0 behind my ID´s.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I got something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;01&lt;/P&gt;&lt;P&gt;01012&lt;/P&gt;&lt;P&gt;01013&lt;/P&gt;&lt;P&gt;01014&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;........&lt;/P&gt;&lt;P&gt;02&lt;/P&gt;&lt;P&gt;02012&lt;/P&gt;&lt;P&gt;02013&lt;/P&gt;&lt;P&gt;........&lt;/P&gt;&lt;P&gt;03&lt;/P&gt;&lt;P&gt;etc....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want to add 3x0 behind the "01" and "02".&lt;/P&gt;&lt;P&gt;It should result in "01000" and "02000". The aim is to get all the ID´s to the same digit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How is this possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 14:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104540#M21813</guid>
      <dc:creator>chofmeister</dc:creator>
      <dc:date>2012-07-11T14:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Edit ID´s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104541#M21814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you wanting to turn 01012 into 01000? or the 01 to 01000?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the ID text or numeric?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have any that are longer than 5 characters such as&amp;nbsp; 101 101013? If so how large to they get?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 14:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104541#M21814</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-07-11T14:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Edit ID´s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104542#M21815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are only two option.&lt;/P&gt;&lt;P&gt;Either the ID´s got 2 or 5 characters. And I need to get the ID´s all to 5 characters. So i want to add three times "0" behind the ID´s with 2 characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable is text.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 14:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104542#M21815</guid>
      <dc:creator>chofmeister</dc:creator>
      <dc:date>2012-07-11T14:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Edit ID´s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104543#M21816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Daja vu:&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="36180" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 14:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104543#M21816</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-07-11T14:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Edit ID´s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104544#M21817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;borrowed Mike's code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id $5.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;01&lt;/P&gt;&lt;P&gt;0101&lt;/P&gt;&lt;P&gt;01013&lt;/P&gt;&lt;P&gt;01014&lt;/P&gt;&lt;P&gt;; &lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if length(id)&amp;lt;5 then id = catt(id,substr('00000',length(id)+1));&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 15:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104544#M21817</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-07-11T15:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Edit ID´s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104545#M21818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IF your variable ID is already defined as 5 characters long, here's a simple way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id = strip(id) || '00000';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, using the newer functions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id = cats(id, '00000');&lt;/P&gt;&lt;P&gt;When the length of ID is defined as 5 characters, any characters beyond the fifth one will be discarded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 15:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104545#M21818</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-07-11T15:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Edit ID´s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104546#M21819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... you are correct in that this ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-size: 12.800000190734863px; background-color: #ffffff;"&gt;id1 = cats(id1, '00000');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;is better than this ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; font-size: 12.800000190734863px; background-color: #ffffff; font-family: 'courier new', courier;"&gt;id1 = cats(id1,substr('0000',length(id1)-1));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;but I do find it "interesting" that this (make a new variable when a LENGTH statement is present in the data step for the new variable) produces an error .and missing value ...&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-size: 12.800000190734863px; background-color: #ffffff;"&gt;id3 = cats(id1, '00000');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12.800000190734863px; background-color: #ffffff; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data ids;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;length id1 $5;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;id1 = '1';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;data ids;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;length id3 id4 $5;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;set ids;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;id2 = id1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;id1 = cats(id1,'0000');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;id2 = cats(id2,'0000');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;id3 = cats(id1,'0000');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;id4 = cats(id1,substr('0000',length(id1)-1));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOG ... ID3 has a LENGTH of 5 but is missing ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;323&amp;nbsp; data ids;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;324&amp;nbsp; length id3 id4 $5;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;325&amp;nbsp; set ids;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;326&amp;nbsp; id2 = id1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;327&amp;nbsp; id1 = cats(id1,'0000');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;328&amp;nbsp; id2 = cats(id2,'0000');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;329&amp;nbsp; id3 = cats(id1,'0000');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;330&amp;nbsp; id4 = cats(id1,substr('0000',length(id1)-1));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;331&amp;nbsp; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;WARNING: In a call to the CATS function, the buffer allocated for the result was not long enough to contain the concatenation of all the arguments. The correct result would contain 9 characters, but the actual result might either be truncated to 5 character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most argument that caused&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; truncation.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;NOTE: Argument 2 to function CATS at line 329 column 7 is invalid.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;id3=&amp;nbsp; id4=10000 id1=10000 id2=10000 _ERROR_=1 _N_=1&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 16:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104546#M21819</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-07-11T16:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Edit ID´s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104547#M21820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Strange, but true.&amp;nbsp; I guess SAS is trying to be efficient by limiting the size of the buffer that CATS uses.&amp;nbsp; But the results become unpredictable, even more so when SAS doesn't tell us what they mean by the "calling environment".&amp;nbsp; I'll stick with my first version then, always pay attention to warnings, and remain vigilant when using new "features."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The results are different when replacing the original variable.&amp;nbsp; I could run this statement twice in a row with no problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id = cats(id, '00000');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 17:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104547#M21820</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-07-11T17:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Edit ID´s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104548#M21821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would prefer to Translate() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data want;
input a $;
&amp;nbsp; length b $ 5;
&amp;nbsp; b=left(a);
&amp;nbsp; b=translate(b,'0',' ');
datalines;
01
01012
01013
01014&amp;nbsp; 
02
02012
02013
03
;
run;






&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jul 2012 03:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-ID-s/m-p/104548#M21821</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-07-12T03:35:35Z</dc:date>
    </item>
  </channel>
</rss>

