I have several datasets I'm trying to set together, but don't want to type each one manually because there are hundreds. Is it possible to use a wildcard to set them together somehow, like you can do in an Infile statement? I've tried Data MyFile; Set MyFile*; Run; but get a syntax error.
Thanks for any help
That was added in 9.2. If you still have an older version, you could either use a pipe or proc sql to accomplish the same thing. E.g.:
proc sql noprint;
select memname into :names
separated by " "
from dictionary.tables
where libname eq "WORK" and
memname like "HAVE%"
;
quit;
data want;
set &names.;
run;
Try it with set Myfile:
Thanks, just tried it however gave me a syntax error again, with the cursor on the ":", very weird...
On SAS 9.2 it works for me. My log shows:
40 data want;
41 set have:;
42 run;
NOTE: There were 7 observations read from the data set WORK.HAVE.
NOTE: There were 7 observations read from the data set WORK.HAVE1.
NOTE: There were 7 observations read from the data set WORK.HAVE2.
NOTE: The data set WORK.WANT has 21 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.07 seconds
cpu time 0.01 seconds
That was added in 9.2. If you still have an older version, you could either use a pipe or proc sql to accomplish the same thing. E.g.:
proc sql noprint;
select memname into :names
separated by " "
from dictionary.tables
where libname eq "WORK" and
memname like "HAVE%"
;
quit;
data want;
set &names.;
run;
Perfect, got them both to work. I'm in Enterprise Guide 4.1 which explains why the colon trick didn't work at first, although as soon as I flipped over to PC SAS 9.2 it worked. The Proc SQL statement worked in both places. Thanks!!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.