Reputation: 763
I have 100 individual data sets of demographic information with distinct district names created in my work folder in the following format";
data exampleofdistrict;
input districtname$ ASIAN BLACK COLORED WHITE;
cards;
Aberdeen 0.13 69.14 11.2 19.5
;
run;
each individual data set like the one above has a district name
What I want is to combine all these individual distrct datasets to into a single comprehensive dataset;
*I have considered using the regular set statment such as;
data districtscompiled;
set Aberdeen and *99 other districts in the work folder;
run;
However, my question is, is there a better way to do this than typing the name of each individual data set under the set statement? For instance, could I maybe do a loop within the set statement?
Upvotes: 0
Views: 462
Reputation: 21264
I would say implement a naming convention, specifically add a prefix to every data set. It could be as simple as _DISTRICTNAME or DIST_Aberdeen, Dist_Banff. Then you can use the short cut notation to set them all at once, using the colon operator or the - data set list option.
data combined;
set dist_: ; *note the colon here!;
run;
If you use a numeric list you can do:
data want;
set district1 - district99; *you need to know the number of districts in this method;
run;
Data Set Lists in documentation
Upvotes: 2