Desktop productivity for business analysts and programmers

Using Wildcard to define filename, but no variables loading on infile

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Using Wildcard to define filename, but no variables loading on infile

I am trying to use a wildcard to load in three sas7bat files that have random dates at the end of their respective file names. I am able to assign the filenames, but what I am having issues understand is how to load the files SAS to use from there. Most post use the data; infile ___; input ___; run; step, but I don't want to specifiy all the input variables as they may change from month to month, I want the code to pull them in automatically as though I were to open the file via the OPEN> DATA menu in Enterprise Guide. 

 

Below is the code and log file that I have so far where it shows it is pulling in zero variables.

filename wm_MP1  "\\SFLC-POD-FS\pod-data3\MDR\&CURRENTMONTH.\FTFR\wholesale_master_*";
filename wm_MP2  "\\SFLC-POD-FS\pod-data3\MDR\&MONTHPREVIOUS.\FTFR\wholesale_master_*";
filename wm_MP3  "\\SFLC-POD-FS\pod-data3\MDR\&TWOMONTHPREVIOUS.\FTFR\wholesale_master_*";

data work.wm_MP1;
        infile wm_MP1;
run;
data work.wm_MP2;
        infile wm_MP2;
run;
data work.wm_MP3;
        infile wm_MP3;
run;

 

LOG FILE:

36         filename wm_MP1  "\\SFLC-POD-FS\pod-data3\MDR\&CURRENTMONTH.\FTFR\wholesale_master_*";
37         filename wm_MP2  "\\SFLC-POD-FS\pod-data3\MDR\&MONTHPREVIOUS.\FTFR\wholesale_master_*";
38         filename wm_MP3  "\\SFLC-POD-FS\pod-data3\MDR\&TWOMONTHPREVIOUS.\FTFR\wholesale_master_*";
39
40         data work.wm_MP1;
41              infile wm_MP1;
42         run;

NOTE: The infile WM_MP1 is:
      Filename=\\SFLC-POD-FS\pod-data3\MDR\2017-04\FTFR\wholesale_master_20170501.sas7bdat,
      RECFM=V,LRECL=32767

NOTE: 0 records were read from the infile WM_MP1.
NOTE: The data set WORK.WM_MP1 has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


43         data work.wm_MP2;
44              infile wm_MP2;
45         run;

NOTE: The infile WM_MP2 is:
      Filename=\\SFLC-POD-FS\pod-data3\MDR\2017-03\FTFR\wholesale_master_20170403.sas7bdat,
      RECFM=V,LRECL=32767

NOTE: 0 records were read from the infile WM_MP2.
NOTE: The data set WORK.WM_MP2 has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


46         data work.wm_MP3;
47              infile wm_MP3;
48         run;

NOTE: The infile WM_MP3 is:
      Filename=\\SFLC-POD-FS\pod-data3\MDR\2017-02\FTFR\wholesale_master_20170301.sas7bdat,
      RECFM=V,LRECL=32767

NOTE: 0 records were read from the infile WM_MP3.
NOTE: The data set WORK.WM_MP3 has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
3                                                          The SAS System                               06:26 Thursday, May 25, 2017

      real time           0.01 seconds

cpu time            0.00 seconds

 

Thanks,

Erin


Accepted Solutions
Solution
‎05-25-2017 11:02 AM
Super User
Posts: 24,010

Re: Using Wildcard to define filename, but no variables loading on infile

Posted in reply to ErinKSimmons

You can't use the wildcard as easily if your datasets are in different folders. But you can assign a library to multiple folders and then try the colon. 

 

libname myfiles ('path to lib1' 'path to lib2' 'path to lib3');

data want;
set myfiles.wholesale_master: ;

run;

View solution in original post


All Replies
Super User
Posts: 24,010

Re: Using Wildcard to define filename, but no variables loading on infile

Posted in reply to ErinKSimmons

It's SET not infile. 

 

Data want;
Set SASHELP.class;
Run;

You also need a libname. 

 


Libname lib1 '\\sflc-pod-...\wholesale_master';

Data wpm1;
Set lib1.wm_mp1;
Run;
Super User
Posts: 24,010

Re: Using Wildcard to define filename, but no variables loading on infile

Posted in reply to ErinKSimmons

It's SET not infile. 

 

Data want;
Set SASHELP.class;
Run;

You also need a libname. 

 


Libname lib1 '\\sflc-pod-...\wholesale_master';

Data wpm1;
Set lib1.wm_mp1;
Run;
Occasional Contributor
Posts: 7

Re: Using Wildcard to define filename, but no variables loading on infile

I tried the libname statement and then but it doesn't allow for the
wildcard in the dataset name. ie wholesale_master_*

-Erin
Super User
Posts: 10,571

Re: Using Wildcard to define filename, but no variables loading on infile

Posted in reply to ErinKSimmons

Try

set lib.wholesale_master_:;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 7

Re: Using Wildcard to define filename, but no variables loading on infile

Posted in reply to KurtBremser

Kurt-

 

Thank you, this also worked as it was part of the other one marked as a solution.

 

-Erin

Solution
‎05-25-2017 11:02 AM
Super User
Posts: 24,010

Re: Using Wildcard to define filename, but no variables loading on infile

Posted in reply to ErinKSimmons

You can't use the wildcard as easily if your datasets are in different folders. But you can assign a library to multiple folders and then try the colon. 

 

libname myfiles ('path to lib1' 'path to lib2' 'path to lib3');

data want;
set myfiles.wholesale_master: ;

run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 424 views
  • 2 likes
  • 3 in conversation