Date: Mon, 18 Aug 2008 23:24:58 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>"
<schreier.junk.mail@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>"
<schreier.junk.mail@GMAIL.COM>
Subject: Re: Parsing FileName into variables
Content-Type: text/plain; charset=ISO-8859-1
On Mon, 18 Aug 2008 17:57:31 -0700, dave crimkey <d_crimkey@YAHOO.COM> wrote:
>This list was a great help a few months back when I had multiple files I
needed to read and they were in 'mac' format.� I'm back to that project now
after being taken off of it for awhile.� My problem now is reading each file
into one dataset and substringing out variable values from the file name.� I
keep getting the following error in SAS
>ERROR: DATA STEP Component Object Failure. Aborted during the COMPILATION
phase.
>�
>I'm trying to read each file in as follows:
>�
>%macro drive(fname);
>data a;
>infile "c:\files\&fname" lrecl=3091 DLM='09'x missover dsd;
>INPUT VAR1-VAR129 ;
>sex = substr(&fname),6,1);
I see an extra right paren. This certainly should have triggered an error.
>subject = substr(&fname,3,3);
>type = substr(&fname,8,4);
The code as written expects there to be a DATA step variable having the name
expressed by the macro variable. You need double quotes around &FNAME so it
is treated as a literal, not a variable name.
>run;
>%mend;
>�
>%drive(A_102m_Bx_1.txt);
Why the semicolon?
>�
>Someone even told me to try double ampersands but that didn't work either.�
Your macro is not that intricate.
I don't understand the error message SAS is giving me.
>�
>I decided I'd worry about appending all the files together once I can get
the variables parsed out of the filename.� But ultimately I'd like to have
one large file.�
>�
>Thanks,
>Dave
>�