| Date: | Mon, 26 Jun 2000 09:08:45 -0400 |
| Reply-To: | Shiferaw_G <Shiferaw_G@BLS.GOV> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Shiferaw_G <Shiferaw_G@BLS.GOV> |
| Subject: | Re: The First Two Character of a file names to be a value in the
filecontent |
| Content-Type: | text/plain; charset="iso-8859-1" |
|---|
I want to thank HTH.; Laurence Adair; Nancy Brucken;
msz03@health.state.ny.us; Michael Thomas for helping me on how to read the
first two characters of multiple files. For sure you saved me time. I used
the following procedure from msz03@health.state.ny.us:
Data Master;
infile datalines;
*** add a LENGTH for variable state (otherwise its length will be 150);
length fil2read $150 state $2;
input fil2read $;
*** extract the value of state from the file name; state =
substr(fil2read,4,2);
infile dummy filevar=fil2read end=done missover DLM = ','; do while (not
done);
input A B C; output;
end; datalines;
G:\AK123.txt
G:\AL2333.txt
G:\AR2333.txt
G:\AZ2344.txt
..
;
run;
Shiferaw_G <Shiferaw_G@BLS.GOV> on 06/20/2000 04:18:21 PM
Please respond to Shiferaw_G <Shiferaw_G@BLS.GOV>
To: SAS-L@LISTSERV.UGA.EDU
cc: (bcc: Michael S. Zdeb/BWH/DFLH/CCH/OPH/DOH)
Subject: The First Two Character of a file names to be a value in the
file
content
I Folks;
I have multiple text files to be read and contained into one file. I am able
to to that Using the following Procedure:
Data Master;
infile datalines;
length fil2read $150;
input fil2read $;
infile dummy filevar=fil2read end=done missover DLM = ','; do while (not
done);
input A B C; output;
end; datalines;
G:\AK123.txt
G:\AL2333.txt
G:\AR2333.txt
G:\AZ2344.txt
..
;
run;
This works perfectly. I need to identify which record comes from which file
(states) in the Master file. That means if the record comes from AK123.txt
the new var name called "State" should have a value 'AK'. How whold I do
that. Note - There is no a vairable called "State" in each file.
Thank you in Advance.
Gabe
|