Visual Binning on a subset of the data file
I would like to use the SPSS Visual Binning procedure to categorize a scale variable called SALNOW. However, I wish to perform the binning only on the male cases in the data set, i.e. those for whom GENDER = 1. If I apply a filter from the Data->Select Cases menu prior to running, Visual Binning, the binning ignores the filter and bins all cases. Likewise, if I sort the file by GENDER and then employ GENDER as a SPLIT FILE variable, the binning process ignores the SPLIT FILE structure. I could paste DO IF and END IF commands around the pasted syntax for the binning, but automated cutpoints in the pasted commands are based on a scan of the full data set. How can I force the binning process to use a subset of the data file that fits a particular condition, such as GENDER = 1.
Resolving the problem
Visual Binning does not honor filters or split file structures. If you enact a filter to temporarily select the cases for whom you want to bin the scale variable, the Visual Binning operation will ignore the filter and bin the scale variable for all cases with valid values on it. Likewise, if you enact a split file structure on the data file, so that procedures are performed separately for cases with each value of the split file variable(s), and then perform visual binning, the binning will be performed on all cases without regard to the split file variable(s). If you paste the syntax for Visual Binning to a syntax window, you will see a set of commands such as the following:
* Visual Binning.
( MISSING = COPY )
( LO THRU 8940 =1 )
( LO THRU 10200 =2 )
( LO THRU 11430 =3 )
( LO THRU 13020 =4 )
( LO THRU HI = 5 )
( ELSE = SYSMIS ) INTO salnow_male.
VARIABLE LABELS salnow_male 'salnow (Binned)'.
FORMAT salnow_male (F5.0).
VALUE LABELS salnow_male
MISSING VALUES salnow_male ( ).
VARIABLE LEVEL salnow_male ( ORDINAL ).
These are dictionary definition and transformation commands, rather than statistical procedures. Dictionary and transformation commands in SPSS are executed without regard to filter or split files, unlike statistical procedures. There are a few workarounds to emply to force the visual binning to be performed on only a subset of the cases. These incclude:
Create copies of the original variable that are conditional on cases belonging to the subgroup in question. For example, if you wish to bin the variable salnow but only for males (gender = 1), then you could copy salnow to sal_male, but only for males, and then run Visual Binning on sal_male. You can perform the conditional transformation in the
Transform->Compute dialog. Type sal_male into the 'Target Variable' box and paste or typesalnow into the 'Numeric Expression' box. Click the 'If' button in the lower left corner of the Compute dialog. In the 'Compute variable:If cases' dialog that opens, click the radio button beside 'Include if case satidfies condition' and type 'gender = 1' into the box (for the example described above) and click Continue and then OK. The corresponding syntax command will look like:
if (gender = 1) sal_male = salnow.
If there are several variables that you wish to conditioally bin, the conditional creation of copy variables appears to be much more efficient than the method described in Method 2 below. If you are comfortable with syntax, you could create all of the copy variables in a set fo commands with one Execute command at the bottom. Then you could run Visual Binning on all of these new variables.
Method 2 .
Rather than applying a filter, delete the cases that do not fi the selection criteria and save the selected cases to a new file or data set name. Perform the visual binning from that data set. You can do a "Merge->Add Variables" operation (or Match Files command to merge the new file to the original file with all cases. The unselected cases will be present by but missing on the new bin-generated variables