f



Returning logical filename when using wildcards w/ INFILE

Hello,

Can somebody please remind me how to programmatically return, in the
data step, the logical filename (and path if possible) of the
currently-processing INFILE when using wildcards.  For example, if I
use the following statement:

FILENAME IN1 "J:\Data\0706\*0706*";

DATA TEST; INFILE IN1 LRECL=705 PAD TRUNCOVER;
          * blaa blaa blaa;
        RUN;

The log tells me (for the first of many files):

NOTE: The infile IN1 is:
      File Name=J:\Data\0706\AE07061,
      File List=J:\Data\0706\*0706*,RECFM=V,
      LRECL=705

How can I get that actual file name i (AE07061) into a variable?

I am hoping to use wildcards and not a directory dump into an INFILE
statement with CARDS or DATALINES.

Thanks in advance,
John

0
8/7/2007 9:49:51 PM
comp.soft-sys.sas 142827 articles. 4 followers. Post Follow

1 Replies
12584 Views

Similar Articles

[PageSpeed] 14

On Aug 7, 10:49 pm, drjaws <jstanme...@gmail.com> wrote:
> Hello,
>
> Can somebody please remind me how to programmatically return, in the
> data step, the logical filename (and path if possible) of the
> currently-processingINFILEwhen using wildcards.  For example, if I
> use the following statement:
>
> FILENAME IN1 "J:\Data\0706\*0706*";
>
> DATA TEST;INFILEIN1 LRECL=705 PAD TRUNCOVER;
>           * blaa blaa blaa;
>         RUN;
>
> The log tells me (for the first of many files):
>
> NOTE: TheinfileIN1 is:
>       File Name=J:\Data\0706\AE07061,
>       File List=J:\Data\0706\*0706*,RECFM=V,
>       LRECL=705
>
> How can I get that actual file name i (AE07061) into a variable?
>
> I am hoping to use wildcards and not a directory dump into anINFILE
> statement with CARDS or DATALINES.
>
> Thanks in advance,
> John

Hi John

your answer comes from the infile option
    FILENAME= {varname}

you provide a wide enough character variable  and input statements
read from the file, the variable name you give will hold that
"external" file name
Try
   data sas_prog_names ;
     length filen $100 ;
     infile '.\*.sas' filename= filen  ;
     input ;
     if filen ne lag(filen) ;
     filename= filen ;
  run;
(hopefully) that creates a dataset of the names of sas program files
in your "current" folder.

 I'm not in a position to check, but I expect that like the dos "dir
*.sas /b" command, you may not get paths unless you apply a path in
the command, like
"dir .\*.sas /b"

SASHELP.VEXTFL and dictionary.extfiles only show the position between
steps, whereas the FILENAME= infile option will show you what happens
~during~ the processing of your data step ~~ including indicating the
all of the names you read through one infile.

hope this helps (I haven't seen it covered in earlier responses)


PeterC

0
8/9/2007 2:27:39 PM
Reply: