I create a number of reports for different constituencies using an SPSS macro. One of these groups only wants data from female respondents, but the rest want both male and female respondents in the data. Is it possible to create a conditional filter in SPSS so that I can use the same loop for all of the reports, or do I have to create a separate syntax for the group that only wants females?
Edit: An abridged version of my code looks like this:
DEFINE !ess1 (inum=!charend ('/')
/ iname=!charend ('/')
/ iname2=!charend ('/')
/ g1=!charend ('/')
/ g2=!charend ('/')
/ g3=!charend ('/')
/ g4=!charend ('/')).
RECODE INST
(!inum=1)
( !g1 = 2)
(!g2= 3)
(!g3=4)
(!g4=5)
into cgroup.
MISSING VALUES cgroup(-9).
variable labels cgroup 'Comparison Group'.
value labels cgroup 1 !iname2 2 'Thing1' 3 'Thing2' 4 'Thing3' 5 'Thing4'.
EXECUTE.
USE ALL.
VARIABLE LEVEL ALL (NOMINAL).
CTABLES
/VLABELS VARIABLES=satisf cgroup DISPLAY=DEFAULT
/TABLE cgroup [ROWPCT.COUNT PCT40.1] BY satisf
/SLABELS VISIBLE=NO
/CATEGORIES VARIABLES=satisf cgroup ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES LABEL="Overall" POSITION=AFTER
MISSING=EXCLUDE
/TITLES
TITLE= 'Overall, how satisfied have you been with this example syntax?'.
DELETE VARIABLES cgroup.
OUTPUT EXPORT
/CONTENTS EXPORT=VISIBLE LAYERS=PRINTSETTING MODELVIEWS=PRINTSETTING
/PDF DOCUMENTFILE=!Quote(!Concat('filepath',!iname,'.pdf'))
EMBEDBOOKMARKS=YES EMBEDFONTS=YES.
OUTPUT SAVE
OUTFILE=!Quote(!Concat('filepath',!iname,'.spv'))
OUTPUT CLOSE *.
OUTPUT NEW.
!ENDDEFINE.
!ess1 inum=1/iname=Name1/ iname2='Name1'/g1= 2,3,4,5,6,7,8,9,10,11,12,13 /g2= 21,22,23,24,25,26,27,29/g3=31,32,33,34,35,36,37,38/g4=41,42,43,44,45/.
!ess1 inum=2 /iname=Name2 /iname2='Name2'/g1= 1,3,4,5,6,7,8,9,10,11,12,13 /g2= 21,22,23,24,25,26,27,29/g3=31,32,33,34,35,36,37,38/g4=41,42,43,44,45/.
!ess1 inum=3 /iname=Name3 /iname2='Name3'/g1= 1,2,4,5,6,7,8,9,10,11,12,13 /g2= 21,22,23,24,25,26,27,29/g3=31,32,33,34,35,36,37,38/g4=41,42,43,44,45/.
Looking at how you have setup this workflow, you could temporarily set the
INST
variable toSYSMIS
for the particular Institutions(?) where you want to exclude males.So adding something like this below to your code:
With
INST
variable now set toSYSMIS
,CTABLES
shall by default exclude these cases in any tabular presentation of the data.