<?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: Seperating the numbers in a single variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Seperating-the-numbers-in-a-single-variable/m-p/736571#M229484</link>
    <description>&lt;P&gt;You can simplify this with the use of dataset options and use of the COUNTW function in the DO statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (rename=(ict=_ict));
do i = 1 to countw(_ict,",");
  ict = scan(_ict,i,",");
  output;
end;
drop i _ict;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Apr 2021 10:13:14 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-04-23T10:13:14Z</dc:date>
    <item>
      <title>Seperating the numbers in a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Seperating-the-numbers-in-a-single-variable/m-p/736558#M229474</link>
      <description>Suppose if dataset contains&lt;BR /&gt;&lt;BR /&gt;Id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ict&lt;BR /&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;BR /&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5,7&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The output dataset should be&lt;BR /&gt;&lt;BR /&gt;Id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ict&lt;BR /&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;BR /&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;BR /&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Suggest me how can I get the output as mentioned above</description>
      <pubDate>Fri, 23 Apr 2021 08:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Seperating-the-numbers-in-a-single-variable/m-p/736558#M229474</guid>
      <dc:creator>Sowmya12</dc:creator>
      <dc:date>2021-04-23T08:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Seperating the numbers in a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Seperating-the-numbers-in-a-single-variable/m-p/736561#M229476</link>
      <description>&lt;P&gt;How about this code?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  length Id 8 ict $8;
  infile datalines dlm=' ';
  input id ict;
datalines;
102 4
103 5,7
;
run;

data want;
  set have;
  tmp_cnt=count(ict,',')+1;
  tmp_ict=ict;
  do i=1 to tmp_cnt;
    ict=scan(tmp_ict,i,',');
    output;
  end;
 
  drop tmp_: i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(modified.)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 09:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Seperating-the-numbers-in-a-single-variable/m-p/736561#M229476</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-23T09:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Seperating the numbers in a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Seperating-the-numbers-in-a-single-variable/m-p/736571#M229484</link>
      <description>&lt;P&gt;You can simplify this with the use of dataset options and use of the COUNTW function in the DO statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (rename=(ict=_ict));
do i = 1 to countw(_ict,",");
  ict = scan(_ict,i,",");
  output;
end;
drop i _ict;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Apr 2021 10:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Seperating-the-numbers-in-a-single-variable/m-p/736571#M229484</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-23T10:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Seperating the numbers in a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Seperating-the-numbers-in-a-single-variable/m-p/736572#M229485</link>
      <description>&lt;P&gt;PS if you want numbers, add an INPUT function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (rename=(ict=_ict));
do i = 1 to countw(_ict,",");
  ict = input(scan(_ict,i,","),32.);
  output;
end;
drop i _ict;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Apr 2021 10:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Seperating-the-numbers-in-a-single-variable/m-p/736572#M229485</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-23T10:16:27Z</dc:date>
    </item>
  </channel>
</rss>

