Quantcast
Channel: Statistics Help @ Talk Stats Forum - SAS
Viewing all articles
Browse latest Browse all 310

SAS Bucketing in intervals

$
0
0
Hi,

Say I have this data:

ID date duration dose
1 02-09-2011 40 100
1 15-11-2011 45 200
1 29-12-2011 46 150
1 02-02-2012 43 300
2 02-09-2011 40 150
2 15-11-2011 45 200
2 29-12-2011 40 250
2 02-02-2012 53 300

In which patients (ID) receive medication on different dates with different doses and duration. I want to bucket these variables in time intervals of 30 days.

And I want it to look like this:
ID date duration dose interval
1 02-09-2011 30 100 1
1 02-09-2011 10 100 2
1 15-11-2011 20 200 2
1 15-11-2011 25 200 3
1 29-12-2011 5 150 3
1 29-12-2011 30 150 4
1 29-12-2011 11 150 5
1 02-02-2012 19 300 5
1 02-02-2012 24 300 6
2 02-09-2011 30 150 1
2 02-09-2011 10 150 2
2 15-11-2011 20 200 2
2 15-11-2011 25 200 3
2 29-12-2011 5 250 3
2 29-12-2011 30 250 4
2 29-12-2011 5 250 5
2 02-02-2012 25 300 5
2 02-02-2012 28 300 6

So each recipe is split over 30 day intervals and intervals are filled with the next recipe. Thus each interval contains 30 days consisting out 1 or more recipes. And for each ID the interval has to start from 1 again.

I found this link:
http://stackoverflow.com/questions/1...amic-interval/

And I was able to make the 30 days intervals, however I couldn't find out how to bucket within one person (ID). I hope someone can help me with this.

Kind regards,
Pauline

Viewing all articles
Browse latest Browse all 310

Trending Articles