k.dkhk
k.dkhk

Reputation: 530

SAS; how to update a data set

I have two datasets, lets say data1 and data2. Those data have same headers (therefore same amount columns).

data test
 set '\\(location on my pc)\data1`;
 keep column1 column2 column3; 
run;

How can I include numbers from from data2. I have (unsuccessfully) tried following:

data test
 set '\\(location on my pc)\data1`;
 set '\\(location on my pc)\data2`;
 keep column1 column2 column3; 
 run;
ANOTHER
data test
 set '\\(location on my pc)\data1` & '\\(location on my pc)\data2`;
 keep column1 column2 column3; 
 run;

Upvotes: 0

Views: 93

Answers (1)

Tom
Tom

Reputation: 51566

If you want to 'stack' the observations from multiple datasets then use a single SET statement.

data want ;
  set table1 table2 ;
run;

If they are already sorted by some key variable(s) then add a by statement and the observations will be interleaved.

data want;
  set table1 table2 ;
  by id;
run;

If you want to add observations to an existing dataset then you can use PROC APPEND.

proc append data=new base=old;
run;

Upvotes: 1

Related Questions