Issue
Let's say I have the following example, with no mandatory questions:
I want to calculate "time_end" and variable's name for "time_end" ("x1") - blue cells.
It would be something like this:
time_end = time of last answered/seen question
x1 = last answered/seen question
All variables AFTER "x1" should then be equal to missing (no answer) and not to "zero".
One of the references to detect these situation, could be that the "time_var" is empty, so no more answers from that point onward, no? But how?
For the ones who answer everything, it's not a problem (see ID=5).
But when I have "drop outs" (quit in middle of questionnaire, do not finish it), I have a syntax where I wrote every variable, by hand, for each one of these ID cases, including naming all variables to be placed missing after a "drop out" (more that 50...).
Is there a way to automatize this with syntax? Thanks!
Solution
Here is one way to do it-
The following code runs through the variables backwards. The first time it meets a time in a time variable, it puts that time in the "time_end" variable and the varname in the x1
variable. It also cleans the varX
along the way:
string x1(a20).
compute time_end=$sysmis.
do repeat tm = time_var6 time_var5 time_var4 time_var3 time_var2 time_var1
/vr = var6 var5 var4 var3 var2 var1
/vrnm = "var6" "var5" "var4" "var3" "var2" "var1" .
if missing(tm) vr=$sysmis.
do if missing(time_end) and not missing(tm).
compute time_end=tm.
compute x1=vrnm.
end if.
end repeat.
formats time_end(time8).
Answered By - eli-k Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.