<?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: Parsing Comma Separated Values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Parsing-Comma-Separated-Values/m-p/302998#M64317</link>
    <description>&lt;P&gt;Amazing! Astounding can you please explain the the logic behind your first step-especially do i=1 by 1, i have never seen something like this before. Thanks.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;It will take two steps, not a single DATA step. &amp;nbsp;Here's one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data b;&lt;/P&gt;
&lt;P&gt;set a;&lt;/P&gt;
&lt;P&gt;rownum = _n_;&lt;/P&gt;
&lt;P&gt;length parse $ 5;&lt;/P&gt;
&lt;P&gt;do i=1 by 1 until (parse=' ');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;parse = scan(ColumnName, i, ',');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if parse &amp;gt; ' ' then output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep parse rownum;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Oct 2016 17:35:31 GMT</pubDate>
    <dc:creator>devsas</dc:creator>
    <dc:date>2016-10-06T17:35:31Z</dc:date>
    <item>
      <title>Parsing Comma Separated Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-Comma-Separated-Values/m-p/302479#M64161</link>
      <description>&lt;P&gt;I have a character column containing comma-separated numbers, and the list of numbers is of varying length. For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;ColumnName&lt;/U&gt;&lt;/P&gt;&lt;P&gt;72,748&lt;/P&gt;&lt;P&gt;980&lt;/P&gt;&lt;P&gt;37449,37451,37452,37453,37454&lt;/P&gt;&lt;P&gt;70286,70287,70288,70290,70291,70292,70293&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to parse ColumnName by putting each number in a separate column. To illustrate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Parse1&lt;/U&gt; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;U&gt;Parse2&lt;/U&gt; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;U&gt;Parse3&lt;/U&gt; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;U&gt;Parse4&lt;/U&gt;&lt;/P&gt;&lt;P&gt;72 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;748&lt;/P&gt;&lt;P&gt;980&lt;/P&gt;&lt;P&gt;37449 &amp;nbsp; &amp;nbsp; &amp;nbsp;37451 &amp;nbsp; &amp;nbsp; &amp;nbsp; 37452 &amp;nbsp; &amp;nbsp; &amp;nbsp;37453 &amp;nbsp; &amp;nbsp; &amp;nbsp;......&lt;/P&gt;&lt;P&gt;70286 &amp;nbsp; &amp;nbsp; &amp;nbsp;70287 &amp;nbsp; &amp;nbsp; &amp;nbsp; 70288 &amp;nbsp; &amp;nbsp; &amp;nbsp;70290 &amp;nbsp; &amp;nbsp; &amp;nbsp;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In a DATA step, I am parsing the comma separated values using the SCAN function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data b; set a;&lt;/P&gt;&lt;P&gt;parse1 = scan(ColumnName, 1, ",");&lt;/P&gt;&lt;P&gt;parse2 = scan(ColumnName, 2, ",");&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I do not know the maximum number of values in the list. So I don't know how many&amp;nbsp;&lt;EM&gt;parseN&lt;/EM&gt; variables to define. Is there a function that can read the list of values in each record and return the max number of values for all the records?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dhrumil Patel&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 22:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-Comma-Separated-Values/m-p/302479#M64161</guid>
      <dc:creator>dhrumil_patel</dc:creator>
      <dc:date>2016-10-04T22:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing Comma Separated Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-Comma-Separated-Values/m-p/302481#M64162</link>
      <description>&lt;P&gt;It will take two steps, not a single DATA step. &amp;nbsp;Here's one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data b;&lt;/P&gt;
&lt;P&gt;set a;&lt;/P&gt;
&lt;P&gt;rownum = _n_;&lt;/P&gt;
&lt;P&gt;length parse $ 5;&lt;/P&gt;
&lt;P&gt;do i=1 by 1 until (parse=' ');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;parse = scan(ColumnName, i, ',');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if parse &amp;gt; ' ' then output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep parse rownum;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose data=b out=want (drop=_name_) prefix=parse;&lt;/P&gt;
&lt;P&gt;by rownum;&lt;/P&gt;
&lt;P&gt;var parse;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 22:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-Comma-Separated-Values/m-p/302481#M64162</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-04T22:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing Comma Separated Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-Comma-Separated-Values/m-p/302998#M64317</link>
      <description>&lt;P&gt;Amazing! Astounding can you please explain the the logic behind your first step-especially do i=1 by 1, i have never seen something like this before. Thanks.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;It will take two steps, not a single DATA step. &amp;nbsp;Here's one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data b;&lt;/P&gt;
&lt;P&gt;set a;&lt;/P&gt;
&lt;P&gt;rownum = _n_;&lt;/P&gt;
&lt;P&gt;length parse $ 5;&lt;/P&gt;
&lt;P&gt;do i=1 by 1 until (parse=' ');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;parse = scan(ColumnName, i, ',');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if parse &amp;gt; ' ' then output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep parse rownum;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2016 17:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-Comma-Separated-Values/m-p/302998#M64317</guid>
      <dc:creator>devsas</dc:creator>
      <dc:date>2016-10-06T17:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing Comma Separated Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-Comma-Separated-Values/m-p/303024#M64328</link>
      <description>&lt;P&gt;do i=1 by 1 until (some condition);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This starts i at 1, and adds 1 each time through the loop.&amp;nbsp; It just doesn't set an upper limit for ending the loop, relying on the DO UNTIL condition to eventually become true.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2016 20:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-Comma-Separated-Values/m-p/303024#M64328</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-06T20:27:49Z</dc:date>
    </item>
  </channel>
</rss>

