<?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: Using infile with several files (*) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275789#M55209</link>
    <description>&lt;P&gt;Have a look at the FILEVAR on the FILENAME statement. It May be what you're lookin for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.google.nl/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=https://support.sas.com/techsup/technote/ts581.pdf&amp;amp;ved=0ahUKEwjwn-LL05bNAhXFXRQKHdklAwwQFggbMAA&amp;amp;usg=AFQjCNHrdJnobEXU7jWqMivpWvI8BYXCOA&amp;amp;sig2=zpsobxJhnxv0l1H73f94Wg" target="_self"&gt;https://support.sas.com/techsup/technote/ts581.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Jan.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jun 2016 19:32:18 GMT</pubDate>
    <dc:creator>jklaverstijn</dc:creator>
    <dc:date>2016-06-07T19:32:18Z</dc:date>
    <item>
      <title>Using infile with several files (*)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275782#M55203</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am doing a datastep with infile. In my infile I have several files with same structure, and with similar name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data customers;&lt;/P&gt;
&lt;P&gt;infile "/home/aps/source/customers_group*;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then I read files customer_group1,&amp;nbsp;&lt;SPAN&gt;customer_group2,....,&amp;nbsp;customer_group8 SAS&amp;nbsp;dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I would likee to know if is possible to create a field with the name of the file of each rows.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For example&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;source= customer_group1 for rows from this file.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Perhaps a system var??&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't have any other field in the files to identify this information.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 18:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275782#M55203</guid>
      <dc:creator>juanvg1972</dc:creator>
      <dc:date>2016-06-07T18:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile with several files (*)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275788#M55208</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/52605"&gt;@juanvg1972﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the FILENAME= option of the INFILE statement to obtain the file name:&lt;/P&gt;
&lt;PRE&gt;data customers;
length fname $300
       source $30; 
infile "/home/aps/source/customers_group*" filename=fname;
source=scan(fname,-1,'/');
...
run;&lt;/PRE&gt;
&lt;P&gt;Variable FNAME is automatically dropped and receives the full path of the currently opened input file, hence the additional assignment statement SOURCE=...&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 19:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275788#M55208</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-07T19:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile with several files (*)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275789#M55209</link>
      <description>&lt;P&gt;Have a look at the FILEVAR on the FILENAME statement. It May be what you're lookin for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.google.nl/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=https://support.sas.com/techsup/technote/ts581.pdf&amp;amp;ved=0ahUKEwjwn-LL05bNAhXFXRQKHdklAwwQFggbMAA&amp;amp;usg=AFQjCNHrdJnobEXU7jWqMivpWvI8BYXCOA&amp;amp;sig2=zpsobxJhnxv0l1H73f94Wg" target="_self"&gt;https://support.sas.com/techsup/technote/ts581.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Jan.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 19:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275789#M55209</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-06-07T19:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile with several files (*)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275790#M55210</link>
      <description>&lt;P&gt;The option on the INFILE statement is FILENAME. The option creates a temporary variable so you need to assign the result to a datastep variable to become a permanent part of the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data new;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* the dataset name will be in varaible dsname you need to ensure the length of it and the temporary variable are long enough to hold the path and name */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; length dsname myfile $ 200;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; infile &amp;nbsp;"/home/aps/source/customers_group*"&amp;nbsp;&amp;nbsp; filename=myfile;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; dsname = myfile;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 19:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275790#M55210</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-07T19:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile with several files (*)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275791#M55211</link>
      <description>&lt;P&gt;Check out the FILENAME option on the INFILE statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#n1rill4udj0tfun1fvce3j401plo.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#n1rill4udj0tfun1fvce3j401plo.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 19:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-with-several-files/m-p/275791#M55211</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-06-07T19:33:02Z</dc:date>
    </item>
  </channel>
</rss>

