<?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: reading input from &amp;quot;file&amp;quot; in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179146#M45734</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;cool&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can I ask how I would read it into a var&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried length line1 $30 line2 $100 ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 May 2014 23:59:36 GMT</pubDate>
    <dc:creator>robm</dc:creator>
    <dc:date>2014-05-30T23:59:36Z</dc:date>
    <item>
      <title>reading input from "file"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179144#M45732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have file that has contents like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;td VALIGN=BASELINE&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;a href="cleopatra/index.html"&amp;gt;Antony and Cleopatra&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br&amp;gt;&amp;lt;a href="coriolanus/index.html"&amp;gt;Coriolanus&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br&amp;gt;&amp;lt;a href="hamlet/index.html"&amp;gt;Hamlet&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and what is outupt by this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_; &lt;/P&gt;&lt;P&gt; length line1 $30 line2 $100 ; &lt;/P&gt;&lt;P&gt; infile main DELIMITER='href=';&lt;/P&gt;&lt;P&gt; input @; &lt;/P&gt;&lt;P&gt;&amp;nbsp; input line1 line2; &lt;/P&gt;&lt;P&gt; put line1= line2= ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;line1=&amp;lt;td VALIGN line2=BASELINE&amp;gt;&lt;/P&gt;&lt;P&gt;line1=&amp;lt;a line2="cl&lt;/P&gt;&lt;P&gt;line1=&amp;lt;b line2=&amp;gt;&amp;lt;a&lt;/P&gt;&lt;P&gt;line1=&amp;lt;b line2=&amp;gt;&amp;lt;a&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what i would like to have output is only the lines with index.html in them &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;line1="cleopatra/index.html" line2=Antony and Cleopatra&lt;/P&gt;&lt;P&gt;line1="coriolanus/index.html" line2=Coriolanus&lt;/P&gt;&lt;P&gt;line1="hamlet/index.html" line2=Hamlet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any ideas on how to do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 22:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179144#M45732</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2014-05-30T22:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: reading input from "file"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179145#M45733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When use use delimeter = 'href' it will trean any of the individual characters as a delimeter, not the whole string.&lt;/P&gt;&lt;P&gt;So since "r" is a delimiter you &amp;lt;b as the "r" was used as a delimiter. Use dlmstr='href' to get the behavior you're looking for. You may&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read the whole line into a single variable and use one of the string search functions such as FINDW or INDEXW. With your example lines you'll need to include / and . in delimiters of the function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if findw(upcase(string),'INDEX',' /.;:') = 0 then delete;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 22:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179145#M45733</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-05-30T22:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: reading input from "file"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179146#M45734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;cool&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can I ask how I would read it into a var&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried length line1 $30 line2 $100 ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 23:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179146#M45734</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2014-05-30T23:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: reading input from "file"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179147#M45735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; Here's a sample program that illustrates the logic using DATALINES or "in-stream" data, as an example of the type of parsing that was suggested..&lt;/P&gt;&lt;P&gt;Cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;data _null_;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; length bigline $100 line1 $50 line2 $100 ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; infile datalines truncover;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; ** read the whole line;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; input @1 bigline $100.;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; ** then parse the lines with HREF and INDEX.HTML only;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; if find(upcase(bigline),'HREF') gt 0 and&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; find(upcase(bigline),'INDEX.HTML') gt 0 then do;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; line1 = scan(bigline,2,'"');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; line2 = scan(bigline,-3,'&amp;lt;&amp;gt;');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put _n_= line1= line2=;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;return;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;datalines4;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;lt;td VALIGN=BASELINE&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;lt;a href="cleopatra/index.html"&amp;gt;Antony and Cleopatra&amp;lt;/a&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;lt;br&amp;gt;&amp;lt;a href="coriolanus/index.html"&amp;gt;Coriolanus&amp;lt;/a&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;lt;br&amp;gt;&amp;lt;a href="hamlet/index.html"&amp;gt;Hamlet&amp;lt;/a&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;;;;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11395iF4AD7DAA5A375E85/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="parse_html.png" title="parse_html.png" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 06:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179147#M45735</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2014-05-31T06:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: reading input from "file"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179148#M45736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines flowover&amp;nbsp; dlm='&amp;lt;&amp;gt;"';&lt;/P&gt;&lt;P&gt;&amp;nbsp; input @'href="' a : $100. @'&amp;gt;' b : $100. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put a= b=;&lt;/P&gt;&lt;P&gt;datalines4;&lt;/P&gt;&lt;P&gt;&amp;lt;td VALIGN=BASELINE&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;a href="cleopatra/index.html"&amp;gt;Antony and Cleopatra&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br&amp;gt;&amp;lt;a href="coriolanus/index.html"&amp;gt;Coriolanus&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br&amp;gt;&amp;lt;a href="hamlet/index.html"&amp;gt;Hamlet&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;run;&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;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: xia keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 06:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179148#M45736</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-05-31T06:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: reading input from "file"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179149#M45737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok cool one last thing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sometimes I have lines like this so line2 is blank until the second line is read &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;a href="allswell/index.html"&amp;gt;&lt;/P&gt;&lt;P&gt;All's Well That Ends Well&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;a href="asyoulikeit/index.html"&amp;gt;&lt;/P&gt;&lt;P&gt;As You Like It&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so I put in logic like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if trim(line2) EQ "" then do &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldline1 = line1;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;end;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*put _n_= line1= line2=;*/&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt; if trim(line2) NE "" then do;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; if trim(line1) EQ "" then do;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; line1 = oldline1;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; put '------------line1 blank ' line1= line2= oldline1=;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; end;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN&gt;&amp;nbsp; put '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://shakespeare.mit.edu/"&gt;http://shakespeare.mit.edu/&lt;/A&gt;&lt;SPAN&gt;' line1 line2 oldline1= ;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so it wont be printed until line2 is populated and line1 is just reassigned to the last line1 (the value of oldline1)&lt;/P&gt;&lt;P&gt;but somewhere oldline1 is getting reset any ideas&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jun 2014 20:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179149#M45737</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2014-06-02T20:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: reading input from "file"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179150#M45738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll need to add: length oldline1 $xxx ; making xxx large enough to hold all the characters expected and then Retain oldline1; to keep the value across records.&lt;/P&gt;&lt;P&gt;AND likely want to reset it to blank when no longer needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jun 2014 21:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179150#M45738</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-06-02T21:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: reading input from "file"</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179151#M45739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK. treat is as a stream file .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data x;&lt;/P&gt;&lt;P&gt; infile 'c:\temp\sample.txt' recfm=n&amp;nbsp; dlm='&amp;lt;&amp;gt;"';&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x : $100. @@ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if lag(x) = 'a href=' or lag2(x)='a href=';&lt;/P&gt;&lt;P&gt;run;&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>Tue, 03 Jun 2014 12:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-input-from-quot-file-quot/m-p/179151#M45739</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-06-03T12:47:29Z</dc:date>
    </item>
  </channel>
</rss>

