<?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: separating a string of digits in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61715#M17524</link>
    <description>var1 = substr(str, 1,1);&lt;BR /&gt;
var2 = substr(str, 2,1);&lt;BR /&gt;
var3 = substr(str, 3,2);</description>
    <pubDate>Wed, 24 Feb 2010 14:36:31 GMT</pubDate>
    <dc:creator>Flip</dc:creator>
    <dc:date>2010-02-24T14:36:31Z</dc:date>
    <item>
      <title>separating a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61714#M17523</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
what is the way to separate a string of digits (e.g. 1103) in 3 different column? I have a string of 4 digits. the first digit symbolize "attribute 1"  the second "attribute 2" the last two the IDnumber. &lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Wed, 24 Feb 2010 14:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61714#M17523</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-02-24T14:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: separating a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61715#M17524</link>
      <description>var1 = substr(str, 1,1);&lt;BR /&gt;
var2 = substr(str, 2,1);&lt;BR /&gt;
var3 = substr(str, 3,2);</description>
      <pubDate>Wed, 24 Feb 2010 14:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61715#M17524</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2010-02-24T14:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: separating a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61716#M17525</link>
      <description>In a DATA step, use the SUBSTR function to parse your data in SAS variable assignment statements.&lt;BR /&gt;
&lt;BR /&gt;
SAS functions are documented here:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000245852.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000245852.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.

Message was edited by: sbb</description>
      <pubDate>Wed, 24 Feb 2010 14:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61716#M17525</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-02-24T14:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: separating a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61717#M17526</link>
      <description>thank you.&lt;BR /&gt;
&lt;BR /&gt;
This works, but only when I import the data as character. &lt;BR /&gt;
&lt;BR /&gt;
When I have Numeric like;&lt;BR /&gt;
&lt;BR /&gt;
Data a;&lt;BR /&gt;
data a;&lt;BR /&gt;
set a;&lt;BR /&gt;
str=1103&lt;BR /&gt;
var1 = substr(str, 1,1);&lt;BR /&gt;
var2 = substr(str, 2,1);&lt;BR /&gt;
var3 = substr(str, 3,2);&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
it doesn't work. &lt;BR /&gt;
&lt;BR /&gt;
When I have used the digits as characters, then I can not convert it back in numeric. The procedure &lt;BR /&gt;
informat var1 var2 best1. var3 best2.;&lt;BR /&gt;
format var1 var2 best1. var3 best2.;&lt;BR /&gt;
can't be interpret by sas.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Thu, 25 Feb 2010 09:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61717#M17526</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-02-25T09:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: separating a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61718#M17527</link>
      <description>Hi Lex,&lt;BR /&gt;
&lt;BR /&gt;
If you'll need to convert it back in numeric you might want to use the input function. And just a curious about this, why convert it back to numeric after you have changed it into a character already? Will you be using the splitted digits for computations?&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Milton</description>
      <pubDate>Thu, 25 Feb 2010 10:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61718#M17527</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2010-02-25T10:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: separating a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61719#M17528</link>
      <description>In order to parse a SAS numeric variable based on digit-position, you must use the SAS PUT function with the desired output FORMAT (second argument), such as Z4., in order to give you a formatted SAS variable/value to parse.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 25 Feb 2010 12:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61719#M17528</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-02-25T12:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: separating a string of digits</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61720#M17529</link>
      <description>The easy way is to [pre]substr(put(x,z4.)...[/pre]  but you can do it with arithmitic functions. &lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
350  data _null_;&lt;BR /&gt;
351     do s = 1103,1010,0330,0901,0001,9999,0000;&lt;BR /&gt;
352        a = int(s/1e3);&lt;BR /&gt;
353        b = int(mod(int(s/1e2),1e1));&lt;BR /&gt;
354        c = int((s/1e2-int(s/1e2))*1e2);&lt;BR /&gt;
355        put (_all_)(=);&lt;BR /&gt;
356        end;&lt;BR /&gt;
357     format s z4. a b f1. c z2.;&lt;BR /&gt;
358     run;&lt;BR /&gt;
&lt;BR /&gt;
s=1103 a=1 b=1 c=03&lt;BR /&gt;
s=1010 a=1 b=0 c=10&lt;BR /&gt;
s=0330 a=0 b=3 c=30&lt;BR /&gt;
s=0901 a=0 b=9 c=01&lt;BR /&gt;
s=0001 a=0 b=0 c=01&lt;BR /&gt;
s=9999 a=9 b=9 c=99&lt;BR /&gt;
s=0000 a=0 b=0 c=00&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 25 Feb 2010 12:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/separating-a-string-of-digits/m-p/61720#M17529</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-02-25T12:51:36Z</dc:date>
    </item>
  </channel>
</rss>

