BookmarkSubscribeRSS Feed
kebowers
Calcite | Level 5

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

 

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

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;

 

Thanks,
Jag
Haikuo
Onyx | Level 15

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)?

PGStats
Opal | Level 21

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)

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1957 views
  • 1 like
  • 4 in conversation