views:

63

answers:

3

Help!

I have 2 variables from different datasets. Each variable has a different name in each dataset. However, the variables are delivering the same type of information for a single resspondent.

Ex.

Variables 1 & 2 for respondent #1

DR1IFDCD 11111000 32104950 51101010 81103080 11111000

DR1IFDCD 92410310 92101000 12210250 31105000 22300140

Any Guidance will be most appreciated.

+1  A: 

I think you are asking how to merge, not stack. In that case, sort your datasets, then merge them...

proc sort data=data1;
    by respondentid;
run;
proc sort data=data2;
    by respondentid;
run;

data newdata;
    merge data1 data2;
    by respondentid;
run;
Rog
+1  A: 

If you truly want to stack (append), there are 2 ways...

data newdata;
    set data1 data2;
run;

or...

proc append base=data1 data=data2;
run;

The latter approach appends one onto the other instead of creating a new dataset.

Rog
+1  A: 

If the variables have different names (name01 for data set data1, name02 for data set data2), you could join the two data sets like this

data newdata;
   set data1(rename=(name01=finalname)) data2(rename=(name02=finalname));
run;

assuming that the data type and length are the same.

Michael Hasan