SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading and Concatenating SAS Data Sets
Concatenating Multiple Data Sets


To concatenate SAS data sets, you specify a list of data set names in the SET statement.


General form, basic DATA step for concatenating:
DATA output-SAS-data-set;
         SET 
SAS-data-set-1 SAS-data-set-2;      
RUN;

where

  • output-SAS-data-set names the data set to be created
  • SAS-data-set-1 and SAS-data-set-2 name the data sets to be read.
Note: You can specify any number of data sets in the SET statement.


For example, the following DATA step creates Clinic.Combined by concatenating Clinic.Therapy1999 and Clinic.Therapy2000.
     data clinic.combined;
        set clinic.therapy1999 clinic.therapy2000;
     run;

Below is the listing of Clinic.Combined.


Obs Month Year AerClass WalkJogRun Swim
1 01 1999 26 78 14
2 02 1999 32 109 19
3 03 1999 15 106 22
4 04 1999 47 115 24
5 05 1999 95 121 31
6 06 1999 61 114 67
7 07 1999 67 102 72
8 08 1999 24 76 77
9 09 1999 78 77 54
10 10 1999 81 62 47
11 11 1999 84 31 52
12 12 1999 92 44 55
13 01 2000 37 91 83
14 02 2000 41 102 27
15 03 2000 52 98 19
16 04 2000 61 118 22
17 05 2000 49 88 29
18 06 2000 24 101 54
19 07 2000 45 91 69
20 08 2000 63 65 53
21 09 2000 60 49 68
22 10 2000 78 70 41
23 11 2000 82 44 58
24 12 2000 93 57 47



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement