<?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: PROC SQL - formatting using SUBSTR in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397182#M95968</link>
    <description>&lt;P&gt;Use the SCAN() function to separate the components.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2017 16:03:04 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-09-19T16:03:04Z</dc:date>
    <item>
      <title>PROC SQL - formatting using SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397181#M95967</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking for some assistance...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with a column containing various member_id's (see below example). I would like the first character, everything left of the dash, to be moved to the end of the string prefixed with two 0's and the dash removed. For example, using the below example, looking at the first member id, I'd like 5-12344 to become 12344005.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;COLUMN A&lt;/P&gt;&lt;P&gt;5-12344&lt;/P&gt;&lt;P&gt;5-1234&lt;/P&gt;&lt;P&gt;5-123456&lt;/P&gt;&lt;P&gt;7-345&lt;/P&gt;&lt;P&gt;2-3456&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 16:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397181#M95967</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-09-19T16:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - formatting using SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397182#M95968</link>
      <description>&lt;P&gt;Use the SCAN() function to separate the components.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 16:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397182#M95968</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-19T16:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - formatting using SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397187#M95970</link>
      <description>&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;cats(scan(a,&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;2&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'-'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;),&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'00'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,scan(a,&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'-'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;))&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 16:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397187#M95970</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-19T16:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - formatting using SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397213#M95980</link>
      <description>&lt;P&gt;Another option -&amp;nbsp;regular expression substitution :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id :$12.;
datalines;
5-12344
5-1234
5-123456
7-345
2-3456
;

proc sql;
select id, prxchange("s/(\d+)\-(\d+)/\200\1/o", 1, id) as newId length=15
from have;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Sep 2017 17:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397213#M95980</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-09-19T17:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - formatting using SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397353#M96033</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both work great! However I now want to increase the length of the string to be length 10 and prefixed with 0's if it is less than this until it reaches the correct length. Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 08:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397353#M96033</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-09-20T08:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - formatting using SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397450#M96057</link>
      <description>&lt;PRE&gt;
data have;
input id :$12.;
datalines;
5-12344
5-1234
5-123456
7-345
2-3456
;
run;
data want;
 set have;
 want=repeat('0',9);
 x=scan(id,1,'-');
 y=scan(id,-1,'-');
 substr(want,1,length(y))=y;
 substr(want,10-length(x)+1)=x;
run;

&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Sep 2017 14:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397450#M96057</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-09-20T14:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - formatting using SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397538#M96083</link>
      <description>&lt;P&gt;Since I was already using heavy artillery, here is&amp;nbsp;some more:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id :$12.;
datalines;
5-12344
5-1234
5-123456
7-345
2-3456
;

proc sql;
select id, 
    put(input(prxchange("s/(\d+)\-(\d+)/\200\1/o", 1, id),10.),z10.0) as newId
from have;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Sep 2017 17:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-formatting-using-SUBSTR/m-p/397538#M96083</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-09-20T17:25:05Z</dc:date>
    </item>
  </channel>
</rss>

