Dear all,
May I have your guidance please on the following:
I have 5 subjects with 5 observations over 15 months period (Day0 ,Day 30, Month 3, month 9 and month 15), and each observation have several measurements (variables)
I want to generate a new variable for each current variable (measurement) that will have a value of the calculated score at month 12.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(participantstudyid visnum) float(visdat daysfscr) byte(tfcscore motscore indepscl sdmt)
3 1 21587   0 12  7 100 38
3 2 21615  28 11 13  85 34
3 3 21698 111 11 11  85 39
3 4 21868 281 13 12 100 40
3 5 22131 544 13 13 100 38
4 1 21594   0 11 31  85 32
4 2 21620  26 11 26  85 38
4 3 21704 110 11 24  85 38
4 4 21872 278 10 28  85 37
4 5 22167 573 10 40  85 36
6 1 21656   0 11 31  85 20
6 2 21679  23 10 33  85 21
6 3 21756 100  9 21  85 28
6 4 21931 275 12 25  85 27
6 5 22195 539  8 36  85 20
1 1 21571   0 12 15  85 35
1 2 21599  28 10 14  85 37
1 3 21677 106 10 15  85 35
1 4 21851 280  7 15  85 30
1 5 22097 526 10 22  90 40
2 1 21579   0 11  3  85 40
2 2 21606  27 11 11  85 45
2 3 21690 111 10 15  75 48
2 4 21858 279 10  9  85 47
2 5 22103 524  9 12  85 40
end
format %td visdat
Please note [daysfscr] is days elapsed from first visit till the visit date.
I want to generate a new variable tfcscore12, which will have a value at the the first observation for each subject only to reflect the annual score ( score at month 12)

I have used the following codes:

Code:
bysort participantstudyid (visdat): gen followup = visdat[_n-4]- visdat if visnum == 1
but I get all missing values for my new variable (25 missing values generated) ( I was expecting 5 values to be generated for each first visit for each participant and 20 missing values for the rest of observations)

and then I was planning to use the code:
Code:
 bysort participantstudyid (visdat): gen d_motscore = ((tfcscore[_n-4]- tfcscore)/followup)* 365.33 if visnum ==1
but since followup variable doesn't have any values I couldn't proceed further.

I hope I made myself clear.

Many thanks in advance for your help in this matter