LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 5 Jan 2011 20:11:33 -0500
Reply-To:   Brian Trautman <btrautman84@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Brian Trautman <btrautman84@GMAIL.COM>
Subject:   Re: Macro Reading Filename

Thank you very much for the help -- the second suggestion worked perfectly. People are used to writing filename statements one way, and I wasn't sure how hard it'd be to get them to do things differently.

If I had to do something like parse the log or the SAS job itself, then I would have bit the bullet and made them change. :)

Brian

On Mon, 3 Jan 2011 17:00:57 -0600, Joe Matise <snoopy369@GMAIL.COM> wrote:

>The LENGTH option is one possibility - it simply gives you the actual length >of the input line. It will NOT directly equal the LRECL value, however, >unless you use PAD; if you don't use PAD, it will give you the actual length >of each input line, which may or may not work for you. It's equivalent to > >input @; >lengthvar = length(_INFILE_); > >from what I recall. But it's only available after read-in, which means you >need to do a quick run through the file first (may be feasible, if it's not >too big, and has the advantage of getting the 'real' LRECL) before creating >your layout. If you are willing to use PAD, then you could do it by only >reading in one line; it still seems more complicated than just using a macro >variable, but it wouldn't be terribly onerous. > > filename fs ftp "'SAMPLE.LOC'" > binary host="srvr" > user=user > pass=pass > lrecl=200 debug ; > >data _NULL_; >infile fs pad length=lenvar; >call symput('lrecl',lenvar); >stop; >run; > >*now you have &LRECL available, without having the user define it that way; > >DATA FFSheet_01_FPPS_Sort ; > > INFILE fs ; > INPUT > @001 Blob $EBCDIC100. > @ ; > >RUN ; > >I don't know of a way to directly get to the LRECL value itself (without >specifying it in a macro variable); the only things I can think of are far >more complicated than telling your users to use macro variables (ie, reading >in your .SAS program itself and parsing it, or reading the log and parsing >that). > >-Joe > >On Mon, Jan 3, 2011 at 4:45 PM, Brian Trautman <btrautman84@gmail.com>wrote: > >> This SAS job processes certain kinds of layout files DB2 produces and makes >> a SAS layout that can work with the unloaded dataset. However, the DB2 >> layout files don't include the length of VARCHAR fields. Most of the time >> this can be derived simply based on wherever the next field starts, but >> this >> doesn't work if the VARCHAR field is the last field in the DB2 unload. In >> those cases, the VARCHAR field is best handled as ending wherever the file >> does. >> >> I won't be the only one using this SAS job, and most of our users wouldn't >> be used to specifying the lrecl in the macro variable, rather than the >> filename statement. That's why I was hoping to, when a varchar was the >> last >> field in an output file, have logic to handle this. >> >> Thank you! >> >> Brian >> >> On Mon, 3 Jan 2011 13:32:47 -0600, Joe Matise <snoopy369@GMAIL.COM> wrote: >> >> >Brian, >> >What's the end goal here? If it's simply to 'do things based on the >> >[provided] LRECL', then %let (or call the macro with the LRECL as a >> >parameter) seems perfectly reasonable. I assume you must have a reason >> for >> >not wanting to do it that way - what is it? Do you want to automatically >> >determine the LRECL? >> > >> >Thanks, >> > >> >Joe >> > >> >On Mon, Jan 3, 2011 at 1:13 PM, Brian Trautman <btrautman84@gmail.com >> >wrote: >> > >> >> I have the following SAS program -- >> >> >> >> filename fs ftp "'SAMPLE.LOC'" >> >> binary host="srvr" >> >> user=user >> >> pass=pass >> >> lrecl=200 >> >> debug ; >> >> >> >> DATA FFSheet_01_FPPS_Sort ; >> >> >> >> INFILE fs ; >> >> INPUT >> >> @001 Blob $EBCDIC100. >> >> @ ; >> >> >> >> RUN ; >> >> >> >> I'd like to be able to write a macro that detects the lrecl used in my >> >> filename statement, and does things based on it. I know one way to do >> it >> >> would be to simply do something like this -- >> >> >> >> %let llen = 200; >> >> >> >> filename fs ftp "'SAMPLE.LOC'" >> >> binary host="srvr" >> >> user=user >> >> pass=pass >> >> lrecl=&llen >> >> debug ; >> >> >> >> However, I'd like to avoid this solution if at all possible. Are there >> any >> >> other options? >> >> >>


Back to: Top of message | Previous page | Main SAS-L page