Prev: SAS => Excel DDE format numbers
Next: how to use variable value as variable in the same dataset
From: sas analysis on 12 Mar 2010 17:26 Hi all, I have a repeated measures dataset sorted by ID. I have age at baseline, visit zero, and would like to add +6 to each visit after. Here is my code: data ageid; set one; BY ID; retain ageid; If first.ID then ageid=age; else ageid=age+6; end; run; My data now looks like this: ID Age 10 74 10 74 10 74 12 50 12 50 13 40 13 40 13 40 would like it to look like this: ID Age 10 74 10 80 10 86 12 50 12 56 13 40 13 46 13 52 any ideas?
From: Patrick on 12 Mar 2010 17:44 Shouldn't that be: else ageid=AGEID+6;
From: Tom Abernathy on 12 Mar 2010 18:26 data ageid; set one; by id; retain year; if first.id then year=0; else year+6; age+year; run; On Mar 12, 5:26 pm, sas analysis <sasanaly...(a)gmail.com> wrote: > Hi all, > > I have a repeated measures dataset sorted by ID. > I have age at baseline, visit zero, and would like to add +6 to each > visit after. > > Here is my code: > > data ageid; > set one; > BY ID; > retain ageid; > If first.ID then ageid=age; else ageid=age+6; > end; > run; > > My data now looks like this: > ID Age > 10 74 > 10 74 > 10 74 > 12 50 > 12 50 > 13 40 > 13 40 > 13 40 > > would like it to look like this: > ID Age > 10 74 > 10 80 > 10 86 > 12 50 > 12 56 > 13 40 > 13 46 > 13 52 > > any ideas?
|
Pages: 1 Prev: SAS => Excel DDE format numbers Next: how to use variable value as variable in the same dataset |