Hi,
I am doing a survival analysis and each row of data contains a date and the number of subjects (separated into female and male dead by columns) that died on that date. For example
16Nov 2015 3 1
18 Nov 2015 5 2
The first line would mean 3 females and 1 male died on 16 Nov and the second would mean 5 females and 2 maled died on 18 Nov. In order to run proc lifetest I need each of the dates where more than 1 subject died to be its own observation, like this:
16 Nov 2015 1 0
16 Nov 2015 1 0
16 Nov 2015 1 0
16 Nov 2015 0 1
18 Nov 2015 1 0
18 Nov 2015 1 0
18 Nov 2015 1 0
18 Nov 2015 1 0
18 Nov 2015 1 0
18 Nov 2015 0 1
18 Nov 2015 0 1
Suggestions greatly appreciated,
Kristen
Please try
data have;
input date :date9. f m;
format date date9.;
cards;
16Nov2015 3 1
18Nov2015 5 2
;
data female male;
set have;
do i = 1 to f;
female=1;
male=0;
output female;
end;
do i = 1 to m;
male=1;
female=0;
output male;
end;
run;
data want;
set female male;
by date;
run;
Your original data does not have enough information to identify censored or event, I am confused how you get to come up that information in your outcome? Unless all of the females are censored, and all of the male are event(death)?
Given your data (date, femaleDeaths, maleDeaths), I think you need the following data organisation for proc lifetest :
data want;
set have;
sex = "Female"; deaths = femaleDeaths; if deaths>0 then output;
sex = "Male"; deaths = maleDeaths; if deaths>0 then output;
keep date sex deaths;
run;
proc lifetest data=want;
time date;
strata sex;
freq deaths;
run;
(untested)
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.