0

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?

Nathan123
  • 763
  • 5
  • 18
  • Why did you split them in the first place, bad design? Do you have a naming convention besides the district names? Can you implement one? If not, are all the data sets in the library going to be combined or only a few? if only a few how are they differentiated? – Reeza Apr 16 '18 at 20:41
  • I can actually implement a naming convention such that each district data set will also have a district number. Example districtname_1. All the datasets in the library have to be combined since they represent all districts from a single province – Nathan123 Apr 16 '18 at 20:45

1 Answers1

2

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

Reeza
  • 20,510
  • 4
  • 21
  • 38