How to collect information from different variables?

Help!

I have 2 variables from different datasets. Each variable has a different name in each dataset. However, the variables provide the same type of information for one respondent.

Ref.

Variables 1 and 2 for Respondent # 1

DR1IFDCD 11111000 32104950 51101010 81103080 11111000

DR1IFDCD 92410310 92101000 12210250 31105000 22300140

The best guidance will be appreciated.

+2


source to share


3 answers


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



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

data newdata;
    merge data1 data2;
    by respondentid;
run;

      

+1


source


If you really want to add (add) there are 2 ways ...

data newdata;
    set data1 data2;
run;

      

or...



proc append base=data1 data=data2;
run;

      

The latter approach adds one to the other instead of creating a new dataset.

+1


source


If the variables have different names (name01 for dataset data1, name02 for data dataset2) you can join two datasets like this

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

      

assuming the data type and length are the same.

+1


source







All Articles