Hi all, I have a longitudinal dataset (N=560) over two waves with an identifier variable called "pid" (I cannot post the dataset here since it is microdata). Everyone has a unique ID and is in wave 1 and wave 2. After cleaning up the dataset, some observations were dropped, meaning that some individuals in both waves are now in only one wave. I want to drop these observations by comparing the ID values in "pid" and generating a new variable called "match" that takes on a value of 1 if the "pid" values are equal, '.' if not. I have the following code:
sort pid
gen match = 0
// Loop through the observations and compare 'pid' values
forvalues i=2/560 {
if pid[`i'] == pid[`i'-1] {
replace match[`i'] = 1
}
}
Each time this returns an error "weights not allowed".
Can anyone help?
sort pid
gen match = 0
// Loop through the observations and compare 'pid' values
forvalues i=2/560 {
if pid[`i'] == pid[`i'-1] {
replace match[`i'] = 1
}
}
Each time this returns an error "weights not allowed".
Can anyone help?
Comment