BookmarkSubscribeRSS Feed
MisterJenn
Fluorite | Level 6

I want to create an indicator variable for 'male' sex. However, I do not have gender or sex as variables in my data set. I have two different data sets (data set for males) and (data set for females). I am trying to combine the two data sets which is why I need help with this. 

 

libname hw6 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Desktop\Assignment 6';
data hw6.sex_f_temp(rename=(subj_id_char=number) drop=subj_id);
set hw6.sex_f;
subj_id_char = input(subj_id, 4.);
run;
proc sort data=hw6.sex_f_temp; by number; 
proc sort data=hw6.sex_m; by number;
data pbc;
set hw6.sex_f_temp hw6.sex_m; 
by number;
logALBUMIN=log(ALBUMIN);
if male = 1 then sex = 1;
if female = 1 then sex=0;
run;
3 REPLIES 3
PaigeMiller
Diamond | Level 26

How about this:

 

data pbc;
set hw6.sex_f_temp(in=f) hw6.sex_m(in=m); 
by number;
if f then sex='F';
else if m then sex='M';
run;
--
Paige Miller
ballardw
Super User

If the idea is to add an indicator based on the source data set use the data set option IN. In creates a 1/0 temporary variable that indicates the current record comes from a given set (1) or not (0). So you can perform any conditional calculations you need to set such things. Below is very generic example

 

data want;
    set dataset1 (in=inset1)
         dataset2 (in= inset2)
   ;
   if inset1 then indicator = 1;
   else if inset2 then indicator=0;
  /* or what ever variable /values you want to set*/
run;
tarheel13
Rhodochrosite | Level 12

unrelated but when getting the log of albumin you should probably only do that when albumin is > 0.