Help using Base SAS procedures

Wildcards in Set Statement?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Wildcards in Set Statement?

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


Accepted Solutions
Solution
‎08-12-2011 11:31 AM
PROC Star
Posts: 7,364

Wildcards in Set Statement?

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;

View solution in original post


All Replies
PROC Star
Posts: 7,364

Wildcards in Set Statement?

Try it with set Myfile:

Occasional Contributor
Posts: 5

Wildcards in Set Statement?

Thanks, just tried it however gave me a syntax error again, with the cursor on the ":", very weird...

PROC Star
Posts: 7,364

Wildcards in Set Statement?

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

Solution
‎08-12-2011 11:31 AM
PROC Star
Posts: 7,364

Wildcards in Set Statement?

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;

Occasional Contributor
Posts: 5

Wildcards in Set Statement?

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

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 3931 views
  • 3 likes
  • 2 in conversation