The examples use generated data (datalines) to create the 'animal' and 'plantG' datasets before their combination.
1 Code Block
DATA STEP Data
Explanation : This SAS code creates two temporary datasets, 'animal' and 'plantG', with internal data. Then, it combines these two datasets using two consecutive SET statements into a new dataset named 'combine'. Each observation from the 'animal' dataset is read, then each corresponding observation (in read order) from the 'plantG' dataset is read. In the case of a common variable ('common'), the value from the last dataset (here 'plantG') overwrites that from the previous one. Proc PRINT displays the content of the 'combine' dataset.
Copied!
data animal;
input common $ animal $;
datalines;
a Ant
b Bird
c Cat
d Dog
e Eagle
f Frog
;
run;
data plantG;
input common $ plant $;
datalines;
a Apple
b Banana
c Coconut
d Dewberry
e Eggplant
g Fig
;
run;
data combine;
set animal;
set plantG;
run;
proc print data=combine; run;
1
DATA animal;
2
INPUT common $ animal $;
3
DATALINES;
4
a Ant
5
b Bird
6
c Cat
7
d Dog
8
e Eagle
9
f Frog
10
;
11
RUN;
12
13
DATA plantG;
14
INPUT common $ plant $;
15
DATALINES;
16
a Apple
17
b Banana
18
c Coconut
19
d Dewberry
20
e Eggplant
21
g Fig
22
;
23
RUN;
24
25
DATA combine;
26
SET animal;
27
SET plantG;
28
RUN;
29
30
PROC PRINTDATA=combine; RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.