Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72771

Recoding time in person-period dataset

$
0
0
Hello Everyone,

I am working with a person-period dataset that I need some help recoding. The data is structured like this, where the number and timing of assessments varies between individuals:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id testtime testtotal time score)
101 1 3   0 25
101 2 3  30 19
101 3 3  45  7
102 1 4   0 78
102 2 4  15 42
102 3 4  29 36
102 4 4  52  5
103 1 5   0 78
103 2 5  17 68
103 3 5  49 20
103 4 5  68 15
103 5 5 102 12
104 0 1   0 45
end
id represents the identifier for each individual
testtime represents the measurement occasion for each assessment
testtotal represents the total number of times an individual was assessed
time represents the number of days that have passed from the 1st assessment to the nth assessment
score represents the score received at each measurement occasion

I would like to create two new time variables. The first would be a variable where 0 represents the ending point of the measurement occasions. The second would be a variable where 0 represents the mid-point. For example, the data for ID 101 would become

id testtime testtotal time score time2 time3
101 1 3 0 25 -45 -30
101 2 3 30 19 -15 0
101 3 3 45 7 0 15

Thank you in advance!

Viewing all articles
Browse latest Browse all 72771

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>