Date: Sat, 11 Jul 2009 13:10:41 -0700
Reply-To: Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Subject: Re: Import Multiple .txt Files
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes
If you're running SAS on Windows, it probably doesn't cost you
anything to experiment, and you'll get to learn about the fabulously
informative SAS error messages. You might want to read the online
help for the INFILE statement at <http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000146932.htm
> (though I don't think it's as helpful as it could be).
Tots units fem força!
On Jul 11, 2009, at 8:30 am, Mojop wrote:
> No error message: just asking before I do it what to do!
> -----Original Message-----
> From: Jack Hamilton [mailto:email@example.com]
> Sent: Saturday, July 11, 2009 2:28 AM
> To: Mojop
> Cc: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: [SAS-L] Import Multiple .txt Files
> It's not the whole program, just the parts that are different.
> Without seeing your code and the error message it's hard to tell
> what the
> problem might be.
> Jack Hamilton
> Tots units fem força!
> On Jul 10, 2009, at 10:49 pm, Mojop wrote:
>> But in your code you've left the infile moh1 but you haven't used
>> filename so is that removed? Or do I create filenames as you've
>> suggested but base it on that?
>> Note that I have tried that but it didn't work because it didn't like
>> the "else" statement after the semi-colon for the final input
>> statement of the first file.
>> -----Original Message-----
>> From: Jack Hamilton [mailto:firstname.lastname@example.org]
>> Sent: Saturday, July 11, 2009 1:41 AM
>> To: shellp
>> Cc: SAS-L@LISTSERV.UGA.EDU
>> Subject: Re: [SAS-L] Import Multiple .txt Files
>> I'm not sure whether the FILENAME= option on the INFILE statement
>> would work in these circumstances, but that's what I would try. Make
>> the input statement dependent on the name of the input file.
>> It would be something like this (untested code):
>> length filename $64.;
>> infile moh1 truncover LRECL = 3000 filename=filename;
>> if filename = 'F:\test\Downloads\file3.txt' then
>> /* input statement for fourth file */ else
>> /* input statement for other files */ =====
>> Jack Hamilton
>> Tots units fem força!
>> On Jul 10, 2009, at 10:15 pm, shellp wrote:
>>> I have 4 text files that have the same data elements but NOT in the
>>> same location yet I want all to be imported into a single file.
>>> Prior to the 4th file I was importing the other 3 with the code
>>> filename moh1('F:\test\Downloads\file1.txt'
>>> 'F:\test\Downloads\file3.txt') infile moh1 truncover
>>> LRECL = 3000;
>>> input @1 Prov $1.
>>> @2 Inst $4.
>>> @6 Fyear $4.
>>> @10 Period $2.
>>> @12 Batch $2.
>>> @14 AbsNo $3.
>>> @71 ProvIss $2.
>>> @73 RFP $2.
>>> @92 Postal $6. ;
>>> How can I import the 4th though the location of "postal" for
>>> is at $105 instead of 92?