I am learning SAS and I am supposed to get this output by sorting and merging my 2 raw datasets. The problem I keep running into is that I get close, but only the first 3 obs are correct. This is my code: filename f1 "C:\Users\Colle\Documents\Grad School\A BINF 5210 Health Data Analytics with SAS\File1-1-1.txt";
filename f2 "C:\Users\Colle\Documents\Grad School\A BINF 5210 Health Data Analytics with SAS\File2-1-1.txt";
run;
data temp;
infile f1 DSD dlm='09'x;
input Salary Location $ ID $ Desc $;
run;
proc sort data=temp;
by ID;
run;
proc print data=temp;
run;
data temp1;
infile f2 DSD dlm='09'x;
input ID $ Gender $ Age Mar_Status $ Weight;
run;
proc sort data=temp1;
by ID;
run;
proc print data=temp1;
run;
data merged_data;
merge temp(in=a) temp1(in=b);
by ID;
if a=1 or b=0;
run;
proc print data=merged_data;
run; This is my output which obviously doesn't match the one I'm supposed to get. I tried all left and right merge combinations. What am I doing wrong? Obs 1-3 are what I need but then obs 4-5 are wrong. I attached my raw data below. Again I am a beginner so I am not supposed to use anything "fancy" or more advanced than this level of sorting/merging/aliases 🙂 Thank you!!
... View more