Professional Documents
Culture Documents
data demog1;
set demog;
format dob1 date9.;
/*creating a new variable for date of birth*/
age = (diagdt-dob1)/365;
output;
trt=2;
output;
run;
data agestats;
set agestats;
length value $10.;
ord= 1;
if _stat_ = 'N' then do; subord=1; value = strip(put(age, 8.));end;
else if _stat_='MEAN' then do; subord =2; value =strip(put(age, 8.1));end;
else if _stat_='STD' then do; subord=3; value = strip(put(age,8.2));end;
else if _stat_ ='MIN' then do; subord=4; value =strip(put(age, 8.1));end;
else if _stat_ ='MAX' then do; subord = 5; value =strip(put(age, 8.1));end;
run;
data demog2;
set demog1;
sex = put(gender, genfmt.);
run;
run;
data genderstats;
set genderstats;
value = cat(count, ' (', strip(put(round(pct_row,.1),8.1)),'%)');
ord =2;
if sex = 'Male' then subord=1;
else subord = 2;
data demog3;
set demog2;
racec = put(race, racefmt.);
run;
data racestats;
set racestats;
value = cat(count, ' (', strip(put(round(pct_row,.1),8.1)), '%)');
ord =3;
if racec='Asian' then subord =1;
else if racec='Black' then subord=2;
else if racec='Hispanic' then subord=3;
else if racec='White' then subord=4;
else if racec='Other' then subord=5;
rename racec = stat;
drop count percent pct_row pct_col;
run;
data final;
length stat $30.;
set t_allstats;
by ord subord;
output;
if first.ord then do;
if ord=1 then stat='Age (years)';
if ord =2 then stat = 'Gender';
if ord=3 then stat = 'Race';
subord=0;
_0='';
_1='';
_2='';
output;
end;