<?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: Different fields to Import per file in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52101#M14325</link>
    <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I'm not sure I'm explaining properly:  I want the contents of multiple text files to be imported into a single SAS data set.&lt;BR /&gt;
&lt;BR /&gt;
All 4 files to import have the same data elements, just located in different sections of the file i.e. postal code is input @72 but for another file postal code is found at location @87.  &lt;BR /&gt;
&lt;BR /&gt;
So there isn't anything unique with the data structure itself, it's the file name and location.   There also isn't any "code path to take" other than what location to identify for the input statement.&lt;BR /&gt;
&lt;BR /&gt;
So if you still think what you're telling me will work can you please provide the code structure using actual code because I don't understand what you're saying?  Thanks.</description>
    <pubDate>Sat, 11 Jul 2009 04:46:34 GMT</pubDate>
    <dc:creator>shellp55</dc:creator>
    <dc:date>2009-07-11T04:46:34Z</dc:date>
    <item>
      <title>Different fields to Import per file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52097#M14321</link>
      <description>Hello&lt;BR /&gt;
&lt;BR /&gt;
I am using SAS 9.1.&lt;BR /&gt;
&lt;BR /&gt;
I have mulitple .txt files and I'm using the infile and input statements to extract the data:&lt;BR /&gt;
&lt;BR /&gt;
filename stuff('c:\mydirectory\fun1.txt' 'c:\mydirectory\fun2.txt' 'c:\mydirectory\fun3.txt)&lt;BR /&gt;
&lt;BR /&gt;
data mylib.test&lt;BR /&gt;
infile stuff;&lt;BR /&gt;
&lt;BR /&gt;
input @1 ID       $1.&lt;BR /&gt;
        @2 Name $15&lt;BR /&gt;
etc.&lt;BR /&gt;
&lt;BR /&gt;
But what if the data elements were the same but located in different areas of the file from one another, is it possible to still have all in the same program i.e. if 'c:\mydirectory\fun1.txt then&lt;BR /&gt;
input @1 ID        $1&lt;BR /&gt;
        @5 Name   $15;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
else if 'c:\mydirectory\fun2.txt then&lt;BR /&gt;
input @1 ID       $1&lt;BR /&gt;
        @ 2 Name $15&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
If not like above then how to do? Thanks.</description>
      <pubDate>Tue, 07 Jul 2009 19:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52097#M14321</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2009-07-07T19:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Different fields to Import per file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52098#M14322</link>
      <description>Using a DATA step approach, use an INPUT statement as shown below to load the input buffer but without reading any variables and use the special SAS variable _INFILE_ to detect what input file format you are expected, then follow that SAS INPUT statement with one or more as determined by the record-format:&lt;BR /&gt;
DATA ....;&lt;BR /&gt;
* START OF YOUR DATA STEP CODE APPEARS HERE. ;&lt;BR /&gt;
INPUT @;&lt;BR /&gt;
IF _INFILE_ =: 'FORMAT1' THEN DO;&lt;BR /&gt;
END;&lt;BR /&gt;
ELSE IF _INFILE_ =: 'FORMAT2' THEN DO;&lt;BR /&gt;
END;&lt;BR /&gt;
ELSE DO;&lt;BR /&gt;
  * SHOULD NOT MAKE IT HERE. ;&lt;BR /&gt;
  ABORT ;&lt;BR /&gt;
END;&lt;BR /&gt;
* MORE OF YOUR DATA STEP CODE APPEARS HERE. ;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 08 Jul 2009 02:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52098#M14322</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-07-08T02:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Different fields to Import per file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52099#M14323</link>
      <description>HI Scott&lt;BR /&gt;
&lt;BR /&gt;
Sorry but I'm still a newbie at this so I'm confused by your answer.&lt;BR /&gt;
&lt;BR /&gt;
Are you saying that I need to create a different set of inputs for every file or just the ones that are different? &lt;BR /&gt;
&lt;BR /&gt;
Where does "format1" and "format2" come from (using my example)?&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Wed, 08 Jul 2009 02:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52099#M14323</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2009-07-08T02:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Different fields to Import per file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52100#M14324</link>
      <description>Only one per each unique format - that being some characteristic of your data structure that appears to be unique, which would be detected by some SAS INPUT statement logic to read a part of the record that appears to be unique.  This logic would determine what code path to take.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 08 Jul 2009 06:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52100#M14324</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-07-08T06:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Different fields to Import per file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52101#M14325</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I'm not sure I'm explaining properly:  I want the contents of multiple text files to be imported into a single SAS data set.&lt;BR /&gt;
&lt;BR /&gt;
All 4 files to import have the same data elements, just located in different sections of the file i.e. postal code is input @72 but for another file postal code is found at location @87.  &lt;BR /&gt;
&lt;BR /&gt;
So there isn't anything unique with the data structure itself, it's the file name and location.   There also isn't any "code path to take" other than what location to identify for the input statement.&lt;BR /&gt;
&lt;BR /&gt;
So if you still think what you're telling me will work can you please provide the code structure using actual code because I don't understand what you're saying?  Thanks.</description>
      <pubDate>Sat, 11 Jul 2009 04:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52101#M14325</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2009-07-11T04:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Different fields to Import per file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52102#M14326</link>
      <description>Hi:&lt;BR /&gt;
  If you look in the documentation on this page:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000146932.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000146932.htm&lt;/A&gt;&lt;BR /&gt;
about the INFILE statement, you will find reference to this topic:&lt;BR /&gt;
"Example 5: Reading from Multiple Input Files" from here&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000146932.htm#a000177201" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000146932.htm#a000177201&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
There you will find 2 different ways to read from multiple input files. The second program under Example 5 uses the FILEVAR method. &lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Sat, 11 Jul 2009 06:38:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Different-fields-to-Import-per-file/m-p/52102#M14326</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-07-11T06:38:53Z</dc:date>
    </item>
  </channel>
</rss>

