Combine repeated measures into single variable (dataset is already in stacked format)

#1
Hello,

I am working with a longitudinal datasset that is already in the stacked/multiple-record/vertical format (there are six entries for each case).

As it stands, there are seven separate variables that measure medication use at the seven time points. I am having a really hard time combining these into one. I tried to use the below syntax, but it restructured the data and made a bunch of extra entries for each case.

VARSTOCASES /ID=id2
/MAKE CombineAD FROM AD_baseline antidep_FU1 antidep_FU2 antidep_FU3
antidep_FU4 antidep_FU5 antidep_FU6
/Index = ALL_AD.

I have attached an excel file showing what I mean. I would REALLY appreciate any help you can give...I am stuck because its repeated measures.

THANK YOU!!!

Sarah
 
#2
Re: Combine repeated measures into single variable (dataset is already in stacked for

It's not clear to me why in the example data there are 3 'True' medication variables (med_time0, Med-time1, Med2) but in your desired output there are 4 (interview0 to interview3). Is this a mistake? If not, can you explain the relationship between the interview variable and the med variables?
 
#3
Re: Combine repeated measures into single variable (dataset is already in stacked for

Oh, I just made up the example. It wasn't perfect (clearly)....as always, you are right. It SHOULD have had the same number. I just wanted to give an illustration of what I meant. I'm sorry...I definitely should have made that better. :-S
 
#4
Re: Combine repeated measures into single variable (dataset is already in stacked for

No worries. I'm just trying to understand what's going on so I can help you. So, is it as simple as a direct relationship between the med variable and the interview value? i.e. if med0 = 1 then cases where interview = 0 should be all_med = 1?

Does this simple example look like what you're after?

Code:
      ID Interview     Med0     Med1     Med2     Med3     Med4   allmed

       1         0        1        1        1        0        0        1
       1         1        1        1        1        0        0        1
       1         2        1        1        1        0        0        1
       1         3        1        1        1        0        0        0
       1         4        1        1        1        0        0        0
       2         0        1        1        0        0        0        1
       2         1        1        1        0        0        0        1
       2         2        1        1        0        0        0        0
       2         3        1        1        0        0        0        0
       2         4        1        1        0        0        0        0
       3         0        1        1        1        1        0        1
       3         1        1        1        1        1        0        1
       3         2        1        1        1        1        0        1
       3         3        1        1        1        1        0        1
       3         4        1        1        1        1        0        0
 
Last edited:
#5
Re: Combine repeated measures into single variable (dataset is already in stacked for

yes, that is exactly right. You got it
 
#6
Re: Combine repeated measures into single variable (dataset is already in stacked for

OK, using the variable information from your first post and assuming your interview variable is ranged from 0 to 6 and that the AD variables are contiguous, this should do what you need.

Code:
compute ALL_AD = 0.
vector x = AD_baseline to antidep_FU6.
loop #i = 1 to 7.
if (interview = #i-1 and x(#i) = 1) ALL_AD = 1.
end loop.
exe.