I have a reshape question. I find this one of the hardest commands to
remember how to use.
I cannot find a help example that exactly parallels my situation. I
have an identifier that is split between variables. This situation is
common in ANOVA where treatment cells may be identified by more than
one factor.
where the first two variables s1level and s1s2delay define 6 treatment
conditions from which s2peakvalue was measured fore each animal. I
would like to reshape this data to calculate a ratio from the
conditions within each animal. I would like to get a data set that
looks like:
in order to calculate a ratios of each of variables 4-7 with the
average of variables 2 and 3. I can do this directly in the long form
by the following code:
egen step = seq(), from(0) to(5) block(1)
gen ppi2 = ((s2peak[_n-step]+s2peak[_n-step+1])/2 -
s2peak[_n])/((s2peak[_n-step]+s2peak[_n-step+1])/2)*100
drop if s1level == 0
but I'm wondering if reshape to wide and then back to long would not be
more reliable. As long as data are not missing, I currently have no
problems. Must I, before I go for wide, say something like,
. egen treatment = group(s1level s1s2delay), label
. drop s1level s1s2delay