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
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;
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;
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;
Kurt-
Thank you, this also worked as it was part of the other one marked as a solution.
-Erin
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.