DATA Step, Macro, Functions and more

set statement

Reply
N/A
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,173

Re: set statement

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


or as data step view avoiding to duplicate data:

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

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.

PeterC
Super Contributor
Super Contributor
Posts: 3,174

Re: set statement

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

SET XXXYYY: ;

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,173

Re: set statement

INDSNAME= !!!

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

Cheers
Patrick
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:
[pre]
proc sql noprint;
select catx('.',LIBNAME,MEMNAME) into: TABS separated by ' ' from DICTIONARY.TABLES
where LIBNAME='' and MEMNAME like '%';
quit;
%put &TABS;

data ALL;
set &TABS;
run;
[/pre]
Cheers from Portugal.

Daniel Santos @ www.cgd.pt
Ask a Question
Discussion stats
  • 5 replies
  • 169 views
  • 0 likes
  • 5 in conversation