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!!
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.
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.