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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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