From: sas analysis on
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
Shouldn't that be: else ageid=AGEID+6;
From: Tom Abernathy on
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?