<?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 INDEX VS RXPARSE &amp; numerical characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INDEX-VS-RXPARSE-numerical-characters/m-p/53076#M11220</link>
    <description>Hello SAS forum;&lt;BR /&gt;
&lt;BR /&gt;
OK, so I am trying to parse specific strings of numbers into individual variables so that I have for example&lt;BR /&gt;
&lt;BR /&gt;
1,2,3&lt;BR /&gt;
1,4,5&lt;BR /&gt;
1,5,7&lt;BR /&gt;
3,10&lt;BR /&gt;
etc etc&lt;BR /&gt;
&lt;BR /&gt;
Here is my problem, if I try to use the index or Rxparse functions for the characters '10'  I still get a 1 if 1 is anywhere in the string. Is there a way to do a literal string match that matches exactly the '10' but not the '1'&lt;BR /&gt;
Thank you.</description>
    <pubDate>Thu, 09 Jul 2009 20:33:58 GMT</pubDate>
    <dc:creator>_LB</dc:creator>
    <dc:date>2009-07-09T20:33:58Z</dc:date>
    <item>
      <title>INDEX VS RXPARSE &amp; numerical characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INDEX-VS-RXPARSE-numerical-characters/m-p/53076#M11220</link>
      <description>Hello SAS forum;&lt;BR /&gt;
&lt;BR /&gt;
OK, so I am trying to parse specific strings of numbers into individual variables so that I have for example&lt;BR /&gt;
&lt;BR /&gt;
1,2,3&lt;BR /&gt;
1,4,5&lt;BR /&gt;
1,5,7&lt;BR /&gt;
3,10&lt;BR /&gt;
etc etc&lt;BR /&gt;
&lt;BR /&gt;
Here is my problem, if I try to use the index or Rxparse functions for the characters '10'  I still get a 1 if 1 is anywhere in the string. Is there a way to do a literal string match that matches exactly the '10' but not the '1'&lt;BR /&gt;
Thank you.</description>
      <pubDate>Thu, 09 Jul 2009 20:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INDEX-VS-RXPARSE-numerical-characters/m-p/53076#M11220</guid>
      <dc:creator>_LB</dc:creator>
      <dc:date>2009-07-09T20:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: INDEX VS RXPARSE &amp; numerical characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INDEX-VS-RXPARSE-numerical-characters/m-p/53077#M11221</link>
      <description>Try INDEXW.  Or possibly explore using the SCAN or FIND functions if these may help.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 09 Jul 2009 20:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INDEX-VS-RXPARSE-numerical-characters/m-p/53077#M11221</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-07-09T20:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: INDEX VS RXPARSE &amp; numerical characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INDEX-VS-RXPARSE-numerical-characters/m-p/53078#M11222</link>
      <description>Hi:&lt;BR /&gt;
  Have you looked at the SCAN function???? If the numbers are -reliably- delimited by ',' (comma), then I'd recommend SCAN...probably inside a do loop. I treated the initial "line" of comma separated data as a character string and then used the SCAN function to split out the numbers. Automatic conversion took place from character to numeric -- which you may want to further control with an INPUT function in the assignment statement. But for a simple example, I didn't bother with an INPUT. I also only showed the comma as a delimiter for the SCAN -- it has a set of defaults that it would otherwise use. You can find those in the doc. The only downside to SCAN that I can think of is that 2 contiguous delimiters would be treated as 1 delimiter.&lt;BR /&gt;
 &lt;BR /&gt;
  If you already have the data in a character variable, then SCAN is what I'd recommend. &lt;BR /&gt;
&lt;BR /&gt;
  If you have the data in a CSV file and want to READ the data into SAS, then I'd recommend using the delimiter= option on the infile statement.  Both techniques are shown below.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
**1) Use SCAN function on character string of numbers delimited by commas;&lt;BR /&gt;
data parse_nums;&lt;BR /&gt;
  length nline $100;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input nline $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1,2,3                              &lt;BR /&gt;
1,4,5                              &lt;BR /&gt;
1,5,7                              &lt;BR /&gt;
3,10                               &lt;BR /&gt;
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                            &lt;BR /&gt;
data separate;&lt;BR /&gt;
  set parse_nums;&lt;BR /&gt;
  array sv num1-num20;&lt;BR /&gt;
  do i = 1 to dim(sv);&lt;BR /&gt;
    sv(i) = scan(nline,i,',');&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
                       &lt;BR /&gt;
proc print data=separate;&lt;BR /&gt;
run;&lt;BR /&gt;
         &lt;BR /&gt;
**2) READ data into numeric vars;&lt;BR /&gt;
data read_nums;&lt;BR /&gt;
  infile datalines delimiter=',' missover;&lt;BR /&gt;
  input var1-var20;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1,2,3                              &lt;BR /&gt;
1,4,5                              &lt;BR /&gt;
1,5,7                              &lt;BR /&gt;
3,10                               &lt;BR /&gt;
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                     &lt;BR /&gt;
proc print data=read_nums;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 09 Jul 2009 20:49:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INDEX-VS-RXPARSE-numerical-characters/m-p/53078#M11222</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-07-09T20:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: INDEX VS RXPARSE &amp; numerical characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INDEX-VS-RXPARSE-numerical-characters/m-p/53079#M11223</link>
      <description>Cynthia; &lt;BR /&gt;
Once again an elegant solution!&lt;BR /&gt;
Thank you.</description>
      <pubDate>Thu, 09 Jul 2009 21:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INDEX-VS-RXPARSE-numerical-characters/m-p/53079#M11223</guid>
      <dc:creator>_LB</dc:creator>
      <dc:date>2009-07-09T21:13:11Z</dc:date>
    </item>
  </channel>
</rss>

