<?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 reading select data from text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404414#M98307</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can any one help me in reading select data from text files&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eg:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name : XYZ&lt;/P&gt;
&lt;P&gt;EMPID:9087&lt;/P&gt;
&lt;P&gt;PIN:1234&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CITY : NY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROD SALE1 SALE2 SALE3&lt;/P&gt;
&lt;P&gt;DVD&amp;nbsp;&amp;nbsp; 21&amp;nbsp;&amp;nbsp; 32&amp;nbsp; 65&lt;/P&gt;
&lt;P&gt;TV&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 25&amp;nbsp;&amp;nbsp; 35&amp;nbsp;&amp;nbsp; 65&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to read only few columns output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EMPID&amp;nbsp; CIYT SALE3&lt;/P&gt;
&lt;P&gt;9087&amp;nbsp; NY 65&lt;/P&gt;
&lt;P&gt;9087&amp;nbsp; NY 65&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Oct 2017 09:59:00 GMT</pubDate>
    <dc:creator>santhosh</dc:creator>
    <dc:date>2017-10-16T09:59:00Z</dc:date>
    <item>
      <title>Reading particular line from text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404384#M98297</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to read a particular lines from text files&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eg: Text file is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*************************************************************/&lt;/P&gt;
&lt;P&gt;Name : XYZ&lt;/P&gt;
&lt;P&gt;phone : 123564&lt;/P&gt;
&lt;P&gt;product : DACXA&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NY&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;prod&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; one&amp;nbsp; &amp;nbsp;two&amp;nbsp; &amp;nbsp;three four&lt;/P&gt;
&lt;P&gt;shoe&amp;nbsp; &amp;nbsp; &amp;nbsp;26&amp;nbsp; &amp;nbsp; &amp;nbsp;25&amp;nbsp; &amp;nbsp; &amp;nbsp; 45&amp;nbsp; &amp;nbsp; &amp;nbsp;65&lt;/P&gt;
&lt;P&gt;AC&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 56&amp;nbsp; &amp;nbsp; &amp;nbsp;89&amp;nbsp; &amp;nbsp; &amp;nbsp; 56&amp;nbsp; &amp;nbsp; &amp;nbsp;87&lt;/P&gt;
&lt;P&gt;Stat&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;63&amp;nbsp; &amp;nbsp; &amp;nbsp;45&amp;nbsp; &amp;nbsp; &amp;nbsp; 23&amp;nbsp; &amp;nbsp; &amp;nbsp;54&lt;/P&gt;
&lt;P&gt;/*************************************************************/&lt;/P&gt;
&lt;P&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i need to create a data set with name,Product city and three columns&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name&amp;nbsp; product city prod&amp;nbsp; three&lt;/P&gt;
&lt;P&gt;XYZ&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;DACXA NY&amp;nbsp; shoe 45&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;XYZ&amp;nbsp; &amp;nbsp;&amp;nbsp;DACXA NY&amp;nbsp; &amp;nbsp;AC&amp;nbsp; &amp;nbsp;56&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;XYZ&amp;nbsp; &amp;nbsp;&amp;nbsp;DACXA NY&amp;nbsp; &amp;nbsp;stat&amp;nbsp; 23&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;can anyone help&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 07:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404384#M98297</guid>
      <dc:creator>santhosh</dc:creator>
      <dc:date>2017-10-16T07:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading particular line from text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404394#M98301</link>
      <description>&lt;P&gt;My suggestion:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length
  line $80.
  name product city prod $10
;
retain name product city;
input;
line = _infile_;
if substr(line,1,2) ne '/*' and line &amp;gt; ' ' and substr(line,4,4) ne 'prod';
if scan(line,1) = 'Name' then name = scan(line,3);
else if scan(line,1) = 'product' then product = scan(line,3);
else if countw(line) = 5
then do;
  prod = scan(line,1);
  three = input(scan(line,4),best.);
  output;
end;
else if substr(line,1,1) ne ' ' then city = line;
drop line;
cards;
/*************************************************************/
Name : XYZ
phone : 123564
product : DACXA
 
NY
   prod          one   two   three four
shoe     26     25      45     65
AC        56     89      56     87
Stat       63     45      23     54
/*************************************************************/
;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;name    product    city    prod    three

XYZ      DACXA      NY     shoe      45 
XYZ      DACXA      NY     AC        56 
XYZ      DACXA      NY     Stat      23 
&lt;/PRE&gt;
&lt;P&gt;Please use the {i} icon in the future for posting textual data, to prevent accidental formatting by the forum SW.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 08:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404394#M98301</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-16T08:00:17Z</dc:date>
    </item>
    <item>
      <title>reading select data from text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404414#M98307</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can any one help me in reading select data from text files&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eg:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name : XYZ&lt;/P&gt;
&lt;P&gt;EMPID:9087&lt;/P&gt;
&lt;P&gt;PIN:1234&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CITY : NY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROD SALE1 SALE2 SALE3&lt;/P&gt;
&lt;P&gt;DVD&amp;nbsp;&amp;nbsp; 21&amp;nbsp;&amp;nbsp; 32&amp;nbsp; 65&lt;/P&gt;
&lt;P&gt;TV&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 25&amp;nbsp;&amp;nbsp; 35&amp;nbsp;&amp;nbsp; 65&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to read only few columns output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EMPID&amp;nbsp; CIYT SALE3&lt;/P&gt;
&lt;P&gt;9087&amp;nbsp; NY 65&lt;/P&gt;
&lt;P&gt;9087&amp;nbsp; NY 65&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 09:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404414#M98307</guid>
      <dc:creator>santhosh</dc:creator>
      <dc:date>2017-10-16T09:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: reading select data from text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404421#M98311</link>
      <description>&lt;P&gt;Adapt my code. The basic logic is the same.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 10:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404421#M98311</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-16T10:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: reading select data from text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404437#M98316</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x1;
infile 'c:\temp\temp.txt' ;
input @'EMPID' empid &amp;amp; $20. @'CITY' city &amp;amp; $20.;
run;
data x2;
infile 'c:\temp\temp.txt' firstobs=8 truncover;
input PROD : $20. SALE1 SALE2 SALE3;
run;
data want;
 set x2;
 if _n_=1 then set x1;
empid=scan(empid,-1,':');
city=scan(city,-1,':');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Oct 2017 12:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-particular-line-from-text-files/m-p/404437#M98316</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-10-16T12:06:21Z</dc:date>
    </item>
  </channel>
</rss>

