<?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 from other table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451618#M113898</link>
    <description>&lt;P&gt;Thanks your code, i like your code. I try it with some errors that i have to study.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Apr 2018 16:41:07 GMT</pubDate>
    <dc:creator>Aleixo</dc:creator>
    <dc:date>2018-04-05T16:41:07Z</dc:date>
    <item>
      <title>Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451575#M113880</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly i did some codes to import multiple files with getnames=yes, correctly done. But now delimiter not worked very well. And i had to do a different code like next one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to read multiple files in a datastep with FORMAT, INFORMART, INFILE, INPUT, etc etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In statement infile i don't know how to do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.INFORMACAO;
  infile datalines dsd truncover;
  input File:$300.;
datalines4;
C:\Users\A.csv
C:\Users\B.csv
;;;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I did from a proc import but the delimiter is complicated because is not standard. I have to fix width each variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now my datastep to "import" all files in my table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data importation;

lenght

.......

;

format

........

;

informat

.......

;

infile File filevar=File end=eof

delimiter='&amp;nbsp;'

MISSOVER

Firstobs=2;

input

.............

;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My problem is in infile step. How i can bring WORK.INFORMACAO from other datastep to this datastep importation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did with a set statement but the result had only 2 observations because of data informacao had 2 observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for ask that question but i never found examples like this or explanation for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aleixo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 15:34:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451575#M113880</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-04-05T15:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451579#M113883</link>
      <description>&lt;P&gt;Use the call execute function.&amp;nbsp; You can find another topic which shows it here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Looping-through-Macro-Execution/m-p/451569/highlight/false#M113879" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Looping-through-Macro-Execution/m-p/451569/highlight/false#M113879&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 15:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451579#M113883</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-05T15:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451596#M113887</link>
      <description>&lt;P&gt;What the purpose of the list of file names?&amp;nbsp; Do you want to read all of those files into a single SAS dataset?&amp;nbsp; or process each one independently into its own SAS dataset?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 15:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451596#M113887</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-05T15:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451598#M113889</link>
      <description>&lt;P&gt;Is better independently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to put in a do while with no result, and try another way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good idea is to put in a datastep with the last name of the folder, like A or B. I have been difficulties to understand loop in SAS. Ina do while loop is easy but in a datastep not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451598#M113889</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-04-05T16:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451601#M113890</link>
      <description>&lt;P&gt;Yes but call execute is in a datastep with set on FilesInFolder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where you call execute? Datastep in a datastep? I think is a wrong idea.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451601#M113890</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-04-05T16:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451604#M113891</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/191516"&gt;@Aleixo&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Is better independently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try to put in a do while with no result, and try another way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good idea is to put in a datastep with the last name of the folder, like A or B. I have been difficulties to understand loop in SAS. Ina do while loop is easy but in a datastep not.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I suspect that you are&amp;nbsp;thinking that you could nest a data step within another data step.&amp;nbsp; You can't do that in SAS. Each step runs on its own.&amp;nbsp; You need to use some type of code generation.&amp;nbsp; CALL EXECUTE() is one way to generate code.&amp;nbsp; Creating a macro that takes the filename as one of its parameters will make it easier to generate the code from a list of files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451604#M113891</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-05T16:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451608#M113892</link>
      <description>&lt;P&gt;Use a SET to include your data set and then you can pass the filenames in using FILEVAR. I believe the documentation under the FILEVAR option under INFILE statement has an example that's along this exact lines, passing the file names.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the files are the same and in the same folder you can try a wild card approach instead, or you can wrap the program in a macro to call it once for each file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not clear to me, which route you're trying to take.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451608#M113892</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-05T16:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451611#M113893</link>
      <description>&lt;P&gt;I did that with filevar and statement SET to bring filenames to datasetp but the result was good for only 2 lines(2 observations) because that Set Work.INFORMATION had only 2 lines that was 2 files path. Do you see?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451611#M113893</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-04-05T16:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451613#M113894</link>
      <description>&lt;P&gt;Your question seems like a modification of this post, where instead of wildcard you need to pass the filename in, is that correct?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Answer:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue you're currently having is that it only processes two files, not the full list?&lt;/P&gt;
&lt;P&gt;Answer:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or is that it's not reading the files at all?&lt;/P&gt;
&lt;P&gt;Answer:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;When generalizing a process, you should first make it work for a single case. Can you provide working code for your one record and we can help you modify it to work with a data set that has the list of files that you want to read in. I don't recall how this method handles the header rows in each file, which is one thing you want to check.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451613#M113894</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-05T16:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451614#M113895</link>
      <description>&lt;P&gt;You can use macros as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   proc sql;
   select count(*), /* Total files */
		  file,/* File name */
		  scan(scan(file,count(file,'\')+1,'\','m'),1,'.') /* Using file name, name for output data set */
		into:Count,:files separated by ',', :DS_name separated by ','
   from WORK.INFORMACAO;
   quit;
%MACRO Read_Files();
%do i=1 %to &amp;amp;Count;
%let Current_File=%SCAN("&amp;amp;Files",&amp;amp;i,',');
%let Dataset_Name=%SCAN("&amp;amp;DS_Name",&amp;amp;i,',');
Data Read_&amp;amp;Dataset_Name;
Infile "&amp;amp;Current_File" firstobs=2;
input File $1000.;
run;
%end;
%Mend Read_Files;
%read_files;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: I didn't test the code, this is just an approach and you need to make some changes as needed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451614#M113895</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-05T16:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451616#M113896</link>
      <description>&lt;P&gt;Please explain the actual problem in more detail.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do the input text files have a consistent format or not?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not then you probably need to use PROC IMPORT so that it can try to figure out the format for you.&lt;/P&gt;
&lt;P&gt;Can you use PROC IMPORT to read them?&amp;nbsp; You mention that the delimiters are non-standard, but PROC IMPORT allows you to specify the delimiter.&amp;nbsp; Do you mean that the delimiters vary between the input files? If so then how do you know which delimiter to use for a particular file in your list?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If they have a consistent format do you want to read all of the files into a single dataset?&amp;nbsp; If so you can just use one data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set INFORMACAO ;
  filename=file;
  infile dummy filevar=filename dsd dlm='{' truncover firstobs=2 end=eof;
  do while (not eof);
    length ..... ;
    format ... ;
    informat ... ;
    input first_var_name -- last_var_name ;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451616#M113896</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-05T16:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451618#M113898</link>
      <description>&lt;P&gt;Thanks your code, i like your code. I try it with some errors that i have to study.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451618#M113898</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-04-05T16:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451619#M113899</link>
      <description>&lt;P&gt;Yes this is a solution. I try and put all my import in same data. It is not my goal but was a very good solution. Now i had to separate the data to have data independentaly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aleixo&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:44:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451619#M113899</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-04-05T16:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Infile from other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451632#M113903</link>
      <description>&lt;P&gt;Just use a BY statement or WHERE statement to process data from a single file.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 17:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-from-other-table/m-p/451632#M113903</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-05T17:06:50Z</dc:date>
    </item>
  </channel>
</rss>

