* Compute the number of consecutive 30 minutes of hypoxia. * Writen by rlevesque@videotron.ca to answer question on SPSS-L. DATA LIST FIXED /dep_int 1-1 do_pc 18-19. BEGIN DATA 1 10-10-97 10:00 48 1 10-10-97 10:30 79 1 10-10-97 11:00 36 1 10-10-97 11:30 24 1 10-10-97 12:00 22 1 10-10-97 12:30 18 1 10-10-97 13:00 57 1 10-10-97 13:30 78 2 10-10-97 14:00 15 2 10-10-97 14:30 10 2 10-10-97 15:00 8 2 10-10-97 15:30 22 2 10-10-97 16:00 38 2 10-10-97 16:30 44 END DATA. LIST. COMPUTE casen=\$casenum. COMPUTE hypoxia=do_pc<28. DO IF \$casenum=1 | (dep_int<>LAG(dep_int)). COMPUTE nb=hypoxia. IF MISSING(nb) nb=0. ELSE. COMPUTE nb=(LAG(nb)+hypoxia)*hypoxia. IF MISSING(nb) nb=0. END IF. EXECUTE. VARIABLE LABEL nb 'nb of consecutive 30 minutes periods of hypoxia'. * run syntax up to here, look at data editor and see if this is on the right track. *----- Flag the records which contain the max number of consecutive 30 minutes. SORT CASES BY casen(D). DO IF \$casenum=1. COMPUTE flag=nb>1. ELSE. COMPUTE flag=(nb>1) &(LAG(nb)=0). END IF. EXECUTE. * Run the syntax up to here, you will see that the cases with flag=1 contain. * the lines with the number of consecutive hypoxia readings in the deployment interval.. SELECT IF flag. * next line recognises that we need 2 consecutive readings to have one 30 minute period. COMPUTE nb=nb-1. EXECUTE. *Show histogram of consecutive 30 minutes periods of hypoxia. GRAPH /HISTOGRAM=nb .