<?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: Manipulate the number in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/347140#M273256</link>
    <description>Thanks for helping me out guys!</description>
    <pubDate>Tue, 04 Apr 2017 18:15:21 GMT</pubDate>
    <dc:creator>Sujithpeta</dc:creator>
    <dc:date>2017-04-04T18:15:21Z</dc:date>
    <item>
      <title>Manipulate the number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346848#M273250</link>
      <description>&lt;P&gt;Hello SAS world,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help with the following problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've a column with a 8&amp;nbsp;digit number, this should be padded with zeros in the appropriate places until the 9&amp;nbsp;digit, 5-4 format is established.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; original data &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; Convert to&lt;/P&gt;&lt;P&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;(4-4) XXXX-XXXX &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&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;(5-4) 0XXXX-XXXX&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&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;(5-3) XXXXX-XXX &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; (5-4) XXXXX-0XXX&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;--Sujith&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346848#M273250</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-04-03T21:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate the number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346852#M273251</link>
      <description>&lt;P&gt;Is this a character variable?&lt;/P&gt;
&lt;P&gt;Can you post some more sample data we can work with?&lt;/P&gt;
&lt;P&gt;Have you looked at the Z5/Z4 formats with a PUT statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 22:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346852#M273251</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-03T22:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate the number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346858#M273252</link>
      <description>&lt;P&gt;Is there a - in the middle of the digits? If not how do you know which part may need the padding? And if the is a - it is not a "number" but a character value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this may get you started.&lt;/P&gt;
&lt;PRE&gt;data junk;
   length x $ 10;
   input x $ 1-9;
   x= catx('-',put(input(scan(x,1),best.),z5.),put(input(scan(x,2),best.),z4.));

datalines;
1234-1234
12345-123
;
run;&lt;/PRE&gt;
&lt;P&gt;Note if your orginal variable is specified as a 9 character field the result will not fit and you'll need the length set before any SET statement to allow the code to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 22:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346858#M273252</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-03T22:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate the number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346859#M273253</link>
      <description>&lt;P&gt;Sample data would help. Here a code sample making assumptions on how your data looks like.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  have=' 4444-333 ';
  /* bit of spaghetti code but should work and doesn't need intermediary variables */
  want=put(input(scan(have,1,'-'),f5.),z5.)||'-'||put(input(scan(have,2,'-'),f4.),z4.);
  output;
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For your real implementation: You probably should also have a check that your source string looks as expected so that you don't unvoluntarily remove digits/characters when converting to your want string.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 22:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346859#M273253</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-04-03T22:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate the number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346868#M273254</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, there is a - in the middle of the digits and it's character (my mistake).&lt;/P&gt;&lt;P&gt;If you don't mind, can you please your 3rd line in your code is doing? It would be a great learning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;--Sujith&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 00:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346868#M273254</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-04-04T00:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate the number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346911#M273255</link>
      <description>&lt;P&gt;you could also try the perl regular expression&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data junk;
   length x $ 10;
   input x $ 1-9;
if prxmatch('m/\d{5,}\-\d{3,}/',x) then new=prxchange('s/(\d{5,})\-(\d{3,})/\1-0\2/',-1,x);
else if prxmatch('m/\d{4,}\-\d{4,}/',x) then new=prxchange('s/(\d{4,})\-(\d{3,})/0\1-\2/',-1,x);
else if prxmatch('m/\d{5,}\-\d{4,}/',x) then new=x;
datalines;
1234-1234
12345-123
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2017 03:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/346911#M273255</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-04-04T03:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate the number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/347140#M273256</link>
      <description>Thanks for helping me out guys!</description>
      <pubDate>Tue, 04 Apr 2017 18:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulate-the-number/m-p/347140#M273256</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-04-04T18:15:21Z</dc:date>
    </item>
  </channel>
</rss>

