BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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 ?
5 REPLIES 5
Patrick
Opal | Level 21
data all;
set sample1 - sample;
run;


or as data step view avoiding to duplicate data:

data all /view=all;
set sample1 - sample;
run;
Peter_C
Rhodochrosite | Level 12
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
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
Patrick
Opal | Level 21
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
DanielSantos
Barite | Level 11
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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1134 views
  • 0 likes
  • 5 in conversation