<?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: infile multiple data one at a time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/infile-multiple-data-one-at-a-time/m-p/127944#M26121</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its rare to have files without extensions, but assuming its true, you could read all the file names in and then parse out only the ones you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Feed that to your input statement or proc import instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This doc shows how to create the file list in a dataset and read them in using a macro loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi29/057-29.pdf" title="http://www2.sas.com/proceedings/sugi29/057-29.pdf"&gt;http://www2.sas.com/proceedings/sugi29/057-29.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Mar 2013 02:18:50 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-03-06T02:18:50Z</dc:date>
    <item>
      <title>infile multiple data one at a time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/infile-multiple-data-one-at-a-time/m-p/127943#M26120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to read in multiple data into SAS.&lt;/P&gt;&lt;P&gt;But the problem is that.. my data has no extension&lt;/P&gt;&lt;P&gt;(eg. drug_15_16, gorc_15_16), so I can only use infile statement to read them into SAS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already have a macro for reading multiple files into SAS, but it uses proc import statement. &lt;/P&gt;&lt;P&gt;So I need to change some parts of the macro. &lt;/P&gt;&lt;P&gt;Could you help me with this? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(I am using Linux operating system)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro data;&lt;/P&gt;&lt;P&gt;%do j=9 %to 10;&lt;/P&gt;&lt;P&gt;%let subdir=/usr17/jhhuh/year&amp;amp;j/toi;&lt;/P&gt;&lt;P&gt;filename dir pipe "ls &amp;amp;subdir/*.dat";&lt;/P&gt;&lt;P&gt;data A;&lt;/P&gt;&lt;P&gt; infile dir truncover end=last expandtabs ;&lt;/P&gt;&lt;P&gt;input filename : $100. @@;&lt;/P&gt;&lt;P&gt;f=scan(filename,1,'.') ;&lt;/P&gt;&lt;P&gt;call symputx(cats('dsn',_n_),f);&lt;/P&gt;&lt;P&gt;filename=cats("&amp;amp;subdir",filename);&lt;/P&gt;&lt;P&gt;call symputx(cats('path',_n_),filename);&lt;/P&gt;&lt;P&gt;if last then call symputx('nobs',_n_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put _user_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro import;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;nobs;&lt;/P&gt;&lt;P&gt;proc import datafile="&amp;amp;&amp;amp;path&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=csv replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getnames=no; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend import;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%import&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend data;&lt;/P&gt;&lt;P&gt;%data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The infile statement is..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a; &lt;/P&gt;&lt;P&gt;infile "path/filenema" firstbos=2;&lt;/P&gt;&lt;P&gt;input v1 v2 v3 v4 v6; &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;I am struggling with this code for almost one week.. &lt;/P&gt;&lt;P&gt;so any advice would be really appreciated! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 23:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/infile-multiple-data-one-at-a-time/m-p/127943#M26120</guid>
      <dc:creator>jhhuh</dc:creator>
      <dc:date>2013-03-05T23:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: infile multiple data one at a time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/infile-multiple-data-one-at-a-time/m-p/127944#M26121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its rare to have files without extensions, but assuming its true, you could read all the file names in and then parse out only the ones you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Feed that to your input statement or proc import instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This doc shows how to create the file list in a dataset and read them in using a macro loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi29/057-29.pdf" title="http://www2.sas.com/proceedings/sugi29/057-29.pdf"&gt;http://www2.sas.com/proceedings/sugi29/057-29.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 02:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/infile-multiple-data-one-at-a-time/m-p/127944#M26121</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-06T02:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: infile multiple data one at a time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/infile-multiple-data-one-at-a-time/m-p/127945#M26122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! I did it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 06:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/infile-multiple-data-one-at-a-time/m-p/127945#M26122</guid>
      <dc:creator>jhhuh</dc:creator>
      <dc:date>2013-03-06T06:44:55Z</dc:date>
    </item>
  </channel>
</rss>

