Sample 24742: Create a new data set from multiple data sets based upon sorted order
Use the SET and BY statements to interleave data sets.
Note: Interleaving uses a SET statement and a BY statement to create
a new, sorted data set from multiple data sets. The number of
observations in the new data set is the sum of the number of
observations in the original data sets. The observations
in the new data set are arranged by the values of the BY
variable(s) and, within each BY-Group, the order of the data
sets in which they occur, including duplicates.
To interleave, data sets need to be in sorted order or indexed
on the BY variables.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
data animal;
input common $ animal $;
datalines;
a Ant
a Ape
b Bird
c Cat
d Dog
;
data plant;
input common $ plant $;
datalines;
a Apple
b Banana
c Coconut
d Dewberry
e Eggplant
f Fig
;
data interleaving;
set animal plant;
by common;
run;
proc print data=interleaving;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs common animal plant
1 a Ant
2 a Ape
3 a Apple
4 b Bird
5 b Banana
6 c Cat
7 c Coconut
8 d Dog
9 d Dewberry
10 e Eggplant
11 f Fig
Use the SET and BY statements to interleave data sets.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> SET Common Programming Tasks ==> Combining Data SAS Reference ==> Statements ==> File-handling ==> SET ==> with BY
|
| Date Modified: | 2008-01-28 11:27:01 |
| Date Created: | 2004-09-30 14:09:09 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |