New Contributor
Posts: 3

# Creating multiple observations from a single observation

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

Posts: 1,147

## Re: Creating multiple observations from a single observation

``````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
Posts: 3,167

## Re: Creating multiple observations from a single observation

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

Posts: 5,523

## Re: Creating multiple observations from a single observation

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
Discussion stats
• 3 replies
• 310 views
• 1 like
• 4 in conversation