Hi, I have a first dataset called "survieH" that looks like this: p1 p2 p3 p4 p5 p6 p7 p8 0,99805395 0,99972943 0,99978889 0,99983248 0,99986097 0,99988087 0,99989295 0,99989952 I have a second dataset called "survieF" that is similar to the first one: p1 p2 p3 p4 p5 p6 p7 p8 0,99829433 0,99976891 0,99982696 0,99986511 0,99989035 0,9999069 0,99991557 0,99992048 Finaly, I have the main database ("bd2006") that contains many observations (30000) and several variables, which "sex" (0-1). I want to create a new dataset that merges them under the condition that if sex=1 then variable I pick the p1-p8 variables in the survieF dataset and if sex=0, I pick the other one. I tried this, without succes: data work.bd2007; set work.bd2006; if _N_ EQ 1 and sex=0 then set survieH ; if _N_ EQ 1 and sex=1 then set survieF ; I know I can do it by doing this, but I want to reduce the size of the dataset, so I don't think it's the best way. data survieH (keep ph1-ph8); set survieH; p1=ph1; ... p8=ph8; run; data work.bd2007; set work.bd2006; if _N_ EQ 1 then do set survieH; set survieF ; end; array ph ph1-ph8; array p p1-p8; do i=1 to 8; if sex=0 then p(i)=ph(i); end; drop ph1-ph8; run;
... View more