|
I need to create quartile variables but I have cases and controls. I need to base the quartiles on the control distribution only. If I use the Frequencies -> Variables -> NTILES command (see below) I get the cut-points in the output. I then use those to RECODE the old variable into a new variable. The trouble with this is that every time the data set changes, this code needs to be redone.
*** select controls only *.
USE ALL.
COMPUTE filter_$=(case_con = 0).
FILTER BY filter_$.
EXECUTE .
*** Put the control only cutpoints into the output *.
FREQUENCIES
VARIABLES=var1
/NTILES= 4
/ORDER= ANALYSIS .
I have also tried:
*** select controls only *.
USE ALL.
COMPUTE filter_$=(case_con = 0).
FILTER BY filter_$.
EXECUTE .
*** Make ranked variables from controls and use lag to assign ranks to the cases *.
RANK
VARIABLES=var1 (A) /NTILES (4) /PRINT=YES
/TIES=LOW .
SORT CASES BY
var1 (A) .
IF($casenum=1) Nvar1=1.
IF(sysmis(Nvar1) = 1) Nvar1 = lag(Nvar1).
formats Nvar1 (F2).
EXECUTE.
The problem with the above is that sometimes the cases are assigned to the wrong group if they are just past the cut-point.
Any ideas for me?
Thanks!
|