<?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: how to import data to SAS without some literals from text file? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-import-data-to-SAS-without-some-literals-from-text-file/m-p/67525#M19316</link>
    <description>There a probably a number of ways.  One might be something like:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data need;&lt;BR /&gt;
  infile "c:\test.txt";&lt;BR /&gt;
  length id $3;&lt;BR /&gt;
  length studentname $10;&lt;BR /&gt;
  input;&lt;BR /&gt;
  if _infile_ ne "" then do;&lt;BR /&gt;
     if anydigit(substr(_infile_,1,1)) then do;&lt;BR /&gt;
      id=scan(_infile_,1);&lt;BR /&gt;
      studentname=scan(_infile_,2);&lt;BR /&gt;
      age=input(scan(_infile_,3),best12.);&lt;BR /&gt;
      weight_pounds=input(scan(_infile_,4),best12.);&lt;BR /&gt;
	  output;&lt;BR /&gt;
    end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Art&lt;BR /&gt;
&amp;gt; I have a text file test.txt like this :&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;    This is class room 1 &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;    ID  STUDENTNAME AGE WEIGHT(pounds)&lt;BR /&gt;
&amp;gt;    1    Robert                 13    70 &lt;BR /&gt;
&amp;gt;  2    Mary                    12    75&lt;BR /&gt;
&amp;gt;    3    Nicole                  11    79&lt;BR /&gt;
&amp;gt;  This is class room 2&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt;    ID  STUDENTNAME AGE WEIGHT(pounds)&lt;BR /&gt;
&amp;gt;     4   charles                15      80&lt;BR /&gt;
&amp;gt;  5    Kathy                  14     85&lt;BR /&gt;
&amp;gt;     6    Jen                     10     70&lt;BR /&gt;
&amp;gt; e above is test.txt file.I have to import it as data&lt;BR /&gt;
&amp;gt; set given below:&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;    ID  STUDENTNAME AGE WEIGHT(pounds)&lt;BR /&gt;
&amp;gt;     1    Robert                 13    70 &lt;BR /&gt;
&amp;gt; 2    Mary                    12    75&lt;BR /&gt;
&amp;gt;     3    Nicole                  11    79&lt;BR /&gt;
&amp;gt; 4   charles                15      80&lt;BR /&gt;
&amp;gt;      5    Kathy                  14     85&lt;BR /&gt;
&amp;gt; 6    Jen                     10     70</description>
    <pubDate>Thu, 19 May 2011 19:50:32 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-05-19T19:50:32Z</dc:date>
    <item>
      <title>how to import data to SAS without some literals from text file?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-import-data-to-SAS-without-some-literals-from-text-file/m-p/67524#M19315</link>
      <description>I have a text file test.txt like this :&lt;BR /&gt;
&lt;BR /&gt;
   This is class room 1 &lt;BR /&gt;
   &lt;BR /&gt;
   ID  STUDENTNAME AGE WEIGHT(pounds)&lt;BR /&gt;
&lt;BR /&gt;
    1    Robert                 13    70 &lt;BR /&gt;
    2    Mary                    12    75&lt;BR /&gt;
    3    Nicole                  11    79&lt;BR /&gt;
&lt;BR /&gt;
  This is class room 2&lt;BR /&gt;
  &lt;BR /&gt;
    ID  STUDENTNAME AGE WEIGHT(pounds)&lt;BR /&gt;
&lt;BR /&gt;
     4   charles                15      80&lt;BR /&gt;
     5    Kathy                  14     85&lt;BR /&gt;
     6    Jen                     10     70&lt;BR /&gt;
&lt;BR /&gt;
The above is test.txt file.I have to import it as data set given below:&lt;BR /&gt;
&lt;BR /&gt;
   ID  STUDENTNAME AGE WEIGHT(pounds)&lt;BR /&gt;
 &lt;BR /&gt;
    1    Robert                 13    70 &lt;BR /&gt;
    2    Mary                    12    75&lt;BR /&gt;
    3    Nicole                  11    79&lt;BR /&gt;
    4   charles                15      80&lt;BR /&gt;
     5    Kathy                  14     85&lt;BR /&gt;
     6    Jen                     10     70</description>
      <pubDate>Thu, 19 May 2011 18:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-import-data-to-SAS-without-some-literals-from-text-file/m-p/67524#M19315</guid>
      <dc:creator>sonyk</dc:creator>
      <dc:date>2011-05-19T18:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to import data to SAS without some literals from text file?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-import-data-to-SAS-without-some-literals-from-text-file/m-p/67525#M19316</link>
      <description>There a probably a number of ways.  One might be something like:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data need;&lt;BR /&gt;
  infile "c:\test.txt";&lt;BR /&gt;
  length id $3;&lt;BR /&gt;
  length studentname $10;&lt;BR /&gt;
  input;&lt;BR /&gt;
  if _infile_ ne "" then do;&lt;BR /&gt;
     if anydigit(substr(_infile_,1,1)) then do;&lt;BR /&gt;
      id=scan(_infile_,1);&lt;BR /&gt;
      studentname=scan(_infile_,2);&lt;BR /&gt;
      age=input(scan(_infile_,3),best12.);&lt;BR /&gt;
      weight_pounds=input(scan(_infile_,4),best12.);&lt;BR /&gt;
	  output;&lt;BR /&gt;
    end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Art&lt;BR /&gt;
&amp;gt; I have a text file test.txt like this :&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;    This is class room 1 &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;    ID  STUDENTNAME AGE WEIGHT(pounds)&lt;BR /&gt;
&amp;gt;    1    Robert                 13    70 &lt;BR /&gt;
&amp;gt;  2    Mary                    12    75&lt;BR /&gt;
&amp;gt;    3    Nicole                  11    79&lt;BR /&gt;
&amp;gt;  This is class room 2&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt;    ID  STUDENTNAME AGE WEIGHT(pounds)&lt;BR /&gt;
&amp;gt;     4   charles                15      80&lt;BR /&gt;
&amp;gt;  5    Kathy                  14     85&lt;BR /&gt;
&amp;gt;     6    Jen                     10     70&lt;BR /&gt;
&amp;gt; e above is test.txt file.I have to import it as data&lt;BR /&gt;
&amp;gt; set given below:&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;    ID  STUDENTNAME AGE WEIGHT(pounds)&lt;BR /&gt;
&amp;gt;     1    Robert                 13    70 &lt;BR /&gt;
&amp;gt; 2    Mary                    12    75&lt;BR /&gt;
&amp;gt;     3    Nicole                  11    79&lt;BR /&gt;
&amp;gt; 4   charles                15      80&lt;BR /&gt;
&amp;gt;      5    Kathy                  14     85&lt;BR /&gt;
&amp;gt; 6    Jen                     10     70</description>
      <pubDate>Thu, 19 May 2011 19:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-import-data-to-SAS-without-some-literals-from-text-file/m-p/67525#M19316</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-05-19T19:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to import data to SAS without some literals from text file?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-import-data-to-SAS-without-some-literals-from-text-file/m-p/67526#M19317</link>
      <description>[pre]&lt;BR /&gt;
data need(drop=row);&lt;BR /&gt;
  infile "c:\temp\test.txt" length=len;&lt;BR /&gt;
  input row $varying200. len;&lt;BR /&gt;
  if not missing(input(scan(row,1),?? best10.)) then do;&lt;BR /&gt;
    id=scan(row,1);studentname=scan(row,2);age=scan(row,3);weight=scan(row,4);&lt;BR /&gt;
    output;&lt;BR /&gt;
                                                 end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 20 May 2011 03:54:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-import-data-to-SAS-without-some-literals-from-text-file/m-p/67526#M19317</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-20T03:54:38Z</dc:date>
    </item>
  </channel>
</rss>

