BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ErinKSimmons
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

6 REPLIES 6
Reeza
Super User

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;
Reeza
Super User

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;
ErinKSimmons
Obsidian | Level 7
I tried the libname statement and then but it doesn't allow for the
wildcard in the dataset name. ie wholesale_master_*

-Erin
ErinKSimmons
Obsidian | Level 7

Kurt-

 

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

 

-Erin

Reeza
Super User

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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