<?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: Scan messy data for values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190401#M48028</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd probably go for a simple scan() for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sample(drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'c:\temp\test.txt' lrecl=1000 dlm=' T';&lt;/P&gt;&lt;P&gt;&amp;nbsp; input @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length Type $40;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain _prxid;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _prxid=prxparse('/(\d+\.\d+)T \$ (\d+\.\d+)/o');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if prxmatch(_prxid,_infile_) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type=scan(_infile_,2,',');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call prxposn(_prxid, 1, _pos);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @_pos Quantity ?? :best32. @;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call prxposn(_prxid, 2, _pos);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @_pos Price ?? :best32.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Oct 2014 03:41:46 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2014-10-21T03:41:46Z</dc:date>
    <item>
      <title>Scan messy data for values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190397#M48024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you anyone for helping with this.&amp;nbsp; I’m trying to pick up&lt;BR /&gt;the values left of ‘T’ and right of ‘$’.&amp;nbsp;&amp;nbsp; Rows without T are&lt;BR /&gt;eliminated.&amp;nbsp;&amp;nbsp; Any help would be appreciated.&amp;nbsp; I can’t get scan( &lt;BR /&gt; to work here for lack of experience. I've tried the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;data test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;infile "j:\test.txt" truncover;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;input i $char100. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;i=upcase(i);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;i = compress(i,',');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;Tons=input(scan(i,10&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New'; font-size: 10pt;"&gt;" "&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New'; font-size: 10pt;"&gt;'b'&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;),&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;6.&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;); /*&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;T and $ seem to be the only consistency&lt;/SPAN&gt;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;Price=input(scan(i,8&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New'; font-size: 10pt;"&gt;" "&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;,'b'),&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;7.&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;); /*&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;s&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;pace as a delimiter is inconsistent */ &lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;BR /&gt;Tons &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;6.2&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; price &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;7.2&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a sample of the text file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Medium square, soy bean straw, on ground 57B $ 17.00 &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;5x6 round, soy bean straw, net wrap, on ground 23B $ 29.00 &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Medium square, alfalfa, 2nd cutting 21.75T $ 180.00 87.39 12.61 18.24 30.5 37.46 162 137&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;3x4 square, alfalfa, 3rd cut 26.64T $ 260.00 85.42 14.58 22.2 29.1 34.21 180 166&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Medium square, alfalfa, 3rd cutting, 48B 25.28T $ 90.00 78.71 21.29 19.14 39.22 45.67 119 95&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Medium square, alfalfa/fescue mix, 4th cutting, 36B 13.26T $ 155.00 84.03 15.97 19.41 36.84 47.07 119 124&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;5x6 round, alfalfa, 3rd cut, net wrap 24.74T $ 215.00 81.77 18.23 21.37 29.85 37.38 163 151&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Large round, grass hay, 1st crop 7.06T $ 85.00 81.83 18.17 12.79 45.22 60.64 82 65&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;4x5 round, grass mix hay, stored inside, 42B 16.21T $ 130.00 86.42 13.58 6.54 39.13 55.52 98 95&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Medium square, grass mix, 24B 8.18T $ 125.00 83.72 16.28 13.59 39.61 51.39 105 97&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;3x4 medium square, wheat straw, roto, stored inside 25.85 $ 112.00 &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Medium square, oat straw 72B $ 30.00 &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;] &amp;amp;#129;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;The file is attached. Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Oct 2014 08:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190397#M48024</guid>
      <dc:creator>jakestat</dc:creator>
      <dc:date>2014-10-18T08:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Scan messy data for values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190398#M48025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want the rows with T but without $ ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data x;
infile 'c:\temp\test.txt' ;
input;
if findc(_infile_,'T') and findc(_infile_,'$') then do;
 var1=scan(_infile_,1,'T');var2=scan(_infile_,-1,'$'); output;
end;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Oct 2014 13:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190398#M48025</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-18T13:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Scan messy data for values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190399#M48026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below code works for the data you've posted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sample(drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'c:\temp\test.txt' lrecl=1000 dlm=' T';&lt;/P&gt;&lt;P&gt;&amp;nbsp; input @;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain _prxid;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _prxid=prxparse('/(\d+\.\d+)T \$ (\d+\.\d+)/o');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if prxmatch(_prxid,_infile_) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call prxposn(_prxid, 1, _pos);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @_pos Quantity ?? :best32. @;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call prxposn(_prxid, 2, _pos);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @_pos Price ?? :best32.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Oct 2014 14:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190399#M48026</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-10-18T14:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Scan messy data for values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190400#M48027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Patric,&amp;nbsp; this works fantastic for picking up Ton and Price value .&amp;nbsp; I did not foresee a pearl response.&amp;nbsp; I had been using a 'class' statement such as&amp;nbsp; indexw(i,"ALFALFA")&amp;nbsp;&amp;nbsp; or GRASS OR STRAW etc.&amp;nbsp; to create a classification by price level variable called 'TYPE'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for lack of experience in Pearl prxparse(...&amp;nbsp; i don't know how to augment your code to include the class ification element to create "TYPE" variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can you give a clue?&amp;nbsp; Thanks you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Oct 2014 16:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190400#M48027</guid>
      <dc:creator>jakestat</dc:creator>
      <dc:date>2014-10-20T16:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Scan messy data for values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190401#M48028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd probably go for a simple scan() for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sample(drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'c:\temp\test.txt' lrecl=1000 dlm=' T';&lt;/P&gt;&lt;P&gt;&amp;nbsp; input @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length Type $40;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain _prxid;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _prxid=prxparse('/(\d+\.\d+)T \$ (\d+\.\d+)/o');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if prxmatch(_prxid,_infile_) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type=scan(_infile_,2,',');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call prxposn(_prxid, 1, _pos);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @_pos Quantity ?? :best32. @;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call prxposn(_prxid, 2, _pos);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input @_pos Price ?? :best32.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 03:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190401#M48028</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-10-21T03:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Scan messy data for values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190402#M48029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As an alternative:&lt;/P&gt;&lt;P&gt;data have (keep=resultt result_dollar);&lt;/P&gt;&lt;P&gt;&amp;nbsp; length resultt result_dollar $200.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array var{20} $200.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile "S:\Temp\Rob\test.txt" dlm=' ' dsd missover lrecl=32767;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input var1-var20 $;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 20;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if index(var{i},"T")&amp;gt;1 then resultt=var{i};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if strip(var{i})="$" then result_dollar=var{i+1};&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 08:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-messy-data-for-values/m-p/190402#M48029</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-10-21T08:55:50Z</dc:date>
    </item>
  </channel>
</rss>

