DATA Step, Macro, Functions and more

set statement

Not applicable
Posts: 0

set statement

Dear All,

I'm having nearly 100 sas datasets with naming convention as sample1, sample2, sample3, etc...Variables are common in all the SAS datasets
how to combine all this ?
Respected Advisor
Posts: 4,736

Re: set statement

Posted in reply to deleted_user
data all;
set sample1 - sample;

or as data step view avoiding to duplicate data:

data all /view=all;
set sample1 - sample;
Valued Guide
Posts: 2,191

Re: set statement

Patrick offers the best solution which is valid since SAS9.2. Before this release we needed to list each of the datasets on a set statement.
Another good feature of SET statement added in SAS9.2 is the option INDSNAME=.
This names a variable that indicates from which of the datasets on the statement the current observation has come.

Super Contributor
Super Contributor
Posts: 3,176

Re: set statement

Also, new with SAS 9.2, the SET statement can specify a file-prefix (stem), such as:


Very helpful with avoiding the need to code NODSNFERR when you are not sure how many "cycles" or "versions" of a given file are available to select.

Scott Barry
SBBWorks, Inc.
Respected Advisor
Posts: 4,736

Re: set statement


Why didn't you tell me earlier! :-)

It's only 2 weeks ago that I ended up doing some complicated coding because I missed this 9.2 enhancement to the set statement.

Thanks for this info Peter. That will come in very handy (also: I should now amend my code...)

Super Contributor
Posts: 474

Re: set statement

Quite a lot of great and interesting new features, thanks for the info!

Since I'm still "stuck" at work with the 9.1.3, here's the alternative:
proc sql noprint;
select catx('.',LIBNAME,MEMNAME) into: TABS separated by ' ' from DICTIONARY.TABLES
where LIBNAME='' and MEMNAME like '%';
%put &TABS;

data ALL;
set &TABS;
Cheers from Portugal.

Daniel Santos @
Ask a Question
Discussion stats
  • 5 replies
  • 5 in conversation