<?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 values seperated by semi-colon in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9748#M767</link>
    <description>The data is in a temporary dataset, not a file.</description>
    <pubDate>Thu, 09 Jun 2011 16:48:59 GMT</pubDate>
    <dc:creator>nickb</dc:creator>
    <dc:date>2011-06-09T16:48:59Z</dc:date>
    <item>
      <title>parsing values seperated by semi-colon</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9743#M762</link>
      <description>I'm working on a report that has copier/printing data and parsing the total pages printed is looking a little tricky.  I have used PROC SQL to get the data from data source but now I'm working on a data step to get pages printed.  &lt;BR /&gt;
&lt;BR /&gt;
Most of the values are stored like:14 x Lgl/D and the total printed would be 14.&lt;BR /&gt;
&lt;BR /&gt;
The other potential combinations:  14 x Lgl/D; 3 x Ltr; 86 x Ltr/D, separated by semi-colons.  So for this transaction the total printed pages would 103 (14+3+86).&lt;BR /&gt;
&lt;BR /&gt;
So I would need a data step that would handle all combinations and sum the total.</description>
      <pubDate>Wed, 08 Jun 2011 19:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9743#M762</guid>
      <dc:creator>nickb</dc:creator>
      <dc:date>2011-06-08T19:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: parsing values seperated by semi-colon</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9744#M763</link>
      <description>You can use a SAS variable in your DATA step along with SCAN to capture each semi-colon delimited, and then use another assignment statement (like more than one for simplicity in coding) to parse each of the sub-records within a "transaction" -- then output one accumulated observation (or otherwise use PROC SUMMARY).&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
scan function parse delimited records site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
scan function site:sas.com</description>
      <pubDate>Wed, 08 Jun 2011 21:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9744#M763</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-06-08T21:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: parsing values seperated by semi-colon</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9745#M764</link>
      <description>You can use compress() to get these digits.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 09 Jun 2011 02:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9745#M764</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-09T02:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: parsing values seperated by semi-colon</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9746#M765</link>
      <description>compress out the semi colon?</description>
      <pubDate>Thu, 09 Jun 2011 14:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9746#M765</guid>
      <dc:creator>nickb</dc:creator>
      <dc:date>2011-06-09T14:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: parsing values seperated by semi-colon</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9747#M766</link>
      <description>if you use an input statement to read these columns, just add ';' to the delimiters defined on the infile statement. The default delimiter is a blank, so you would be adding the option to the infile statement like&lt;BR /&gt;
input 'the file you read' dlm=' ;' other options like lrecl=1000  and truncover ;&lt;BR /&gt;
  &lt;BR /&gt;
proc import offers less flexibility (I think) &lt;BR /&gt;
 &lt;BR /&gt;
peterC</description>
      <pubDate>Thu, 09 Jun 2011 16:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9747#M766</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-06-09T16:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: parsing values seperated by semi-colon</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9748#M767</link>
      <description>The data is in a temporary dataset, not a file.</description>
      <pubDate>Thu, 09 Jun 2011 16:48:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9748#M767</guid>
      <dc:creator>nickb</dc:creator>
      <dc:date>2011-06-09T16:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: parsing values seperated by semi-colon</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9749#M768</link>
      <description>Sometimes it is worth loading a string into  _INFILE_ just to get the sophisticated parsing available with INPUT</description>
      <pubDate>Thu, 09 Jun 2011 17:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9749#M768</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-06-09T17:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: parsing values seperated by semi-colon</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9750#M769</link>
      <description>I don't see example online on how to do this?&lt;BR /&gt;
&lt;BR /&gt;
I have try this approach:&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
set work.adjunct_copy;&lt;BR /&gt;
copies=substr(copy_pages,1, index(copy_pages,'x')-1);  &amp;gt;&amp;gt;only 1 value is stored in the row&lt;BR /&gt;
IF findc(Copy_Pages, ';')&amp;gt;1 then;&lt;BR /&gt;
  do while (findc(copy_pages, ';')=0);  &amp;gt;&amp;gt;&amp;gt; loop for more than one&lt;BR /&gt;
      copies=substr(copy_pages,1, index(copy_pages,'x')-1);&lt;BR /&gt;
  end;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 09 Jun 2011 20:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9750#M769</guid>
      <dc:creator>nickb</dc:creator>
      <dc:date>2011-06-09T20:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: parsing values seperated by semi-colon</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9751#M770</link>
      <description>Here is one sample approach using a DO/END to parse through each logical within a physical record:&lt;BR /&gt;
&lt;BR /&gt;
10   data _null_;&lt;BR /&gt;
11   infile "c:\temp\parse_data_sas.txt";&lt;BR /&gt;
12   input ;&lt;BR /&gt;
13   length tempvar $100;&lt;BR /&gt;
14   do i=1 to countw(_infile_,';');&lt;BR /&gt;
15     tempvar = scan(_infile_,i,';');&lt;BR /&gt;
16     putlog _all_;&lt;BR /&gt;
17     * add code here to parse each sub-field. ;&lt;BR /&gt;
18   end;&lt;BR /&gt;
19   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The infile "c:\temp\parse_data_sas.txt" is:&lt;BR /&gt;
      Filename=c:\temp\parse_data_sas.txt,&lt;BR /&gt;
      RECFM=V,LRECL=256,File Size (bytes)=43,&lt;BR /&gt;
      Last Modified=09Jun2011:16:35:41,&lt;BR /&gt;
      Create Time=09Jun2011:16:35:41&lt;BR /&gt;
&lt;BR /&gt;
tempvar=14 x Lgl/D i=1 _ERROR_=0 _INFILE_=14 x Lgl/D; 3 x Ltr; 86 x Ltr/D _N_=1&lt;BR /&gt;
tempvar=3 x Ltr i=2 _ERROR_=0 _INFILE_=14 x Lgl/D; 3 x Ltr; 86 x Ltr/D _N_=1&lt;BR /&gt;
tempvar=86 x Ltr/D i=3 _ERROR_=0 _INFILE_=14 x Lgl/D; 3 x Ltr; 86 x Ltr/D _N_=1&lt;BR /&gt;
tempvar=18 x Lgl/D i=1 _ERROR_=0 _INFILE_=18 x Lgl/D _N_=2&lt;BR /&gt;
NOTE: 2 records were read from the infile "c:\temp\parse_data_sas.txt".&lt;BR /&gt;
      The minimum record length was 10.&lt;BR /&gt;
      The maximum record length was 31.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.02 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 09 Jun 2011 20:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/parsing-values-seperated-by-semi-colon/m-p/9751#M770</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-06-09T20:40:25Z</dc:date>
    </item>
  </channel>
</rss>

