*(Q) I am creating a large number of bar charts. For each chart I must exclude any categories that have fewer than 10 students. I have been running frequencies and then manually clicking on each category that was to be omitted, but I know there must be a better way. Any ideas would be greatly appreciated. *(A) Posted to SPSSX-L list by rlevesque@videotron.ca on 2001/09/21 Two different macros are included. Select the one which best meet your requirements. DATA LIST LIST /age prog year. BEGIN DATA 25 1 2 25 1 2 25 1 2 25 1 2 25 1 4 25 1 4 25 1 4 25 1 4 25 1 4 25 1 4 25 1 7 25 1 7 25 1 7 25 1 7 25 1 2 26 1 2 27 2 1 27 2 1 27 2 1 27 2 1 27 2 1 27 2 1 END DATA. COMPUTE dummy=1. SET MPRINT=no. *////////////////////. DEFINE !chart (minnb=!TOKENS(1) /cat=!TOKENS(1)) FILTER OFF. * Sorting is necessary for the MATCH FILES command. SORT CASES BY !cat. !LET !fname=!QUOTE(!CONCAT('C:\\temp\\',!cat,'.SAV')) AGGREGATE /OUTFILE=!fname /PRESORTED /BREAK=!cat /nb = N(dummy). MATCH FILES /FILE=* /TABLE=!fname /BY !cat. FREQUENCY VARIABLES=!cat. COMPUTE flag=(nb>=!minnb). FILTER BY flag. GRAPH /BAR(SIMPLE)=COUNT BY !cat /MISSING=REPORT. * Delete the variable nb. MATCH FILES FILE=* /DROP=nb. !ENDDEFINE. *////////////////////. SET MPRINT=yes. !chart minnb=5 cat=age. !chart minnb=6 cat=prog. !chart minnb=5 cat=year. * The above method is ok if you need to do other things between the printing of the charts. * The following macro is ok if all you need is to print the bar charts and the same min number of cases is required.. SET MPRINT=no. *////////////////////. DEFINE !chart2 (minnb=!TOKENS(1) /cats=!CMDEND) /* minnb = minimum number of cases required in order to chart category value*/. /* cats = names of the categorical variables to be charted*/. COMPUTE dummy=1. !DO !cat !IN (!cats) FILTER OFF. * Sorting is necessary for the MATCH FILES command. SORT CASES BY !cat. !LET !fname=!QUOTE(!CONCAT('C:\\temp\\',!cat,'.SAV')) AGGREGATE /OUTFILE=!fname /PRESORTED /BREAK=!cat /nb = N(dummy). MATCH FILES /FILE=* /TABLE=!fname /BY !cat. FREQUENCY VARIABLES=!cat. LIST. COMPUTE flag=(nb>=!minnb). FILTER BY flag. GRAPH /BAR(SIMPLE)=COUNT BY !cat /MISSING=REPORT. * Delete the variable nb. MATCH FILES FILE=* /DROP=nb. !DOEND * Delete the variable nb. MATCH FILES FILE=* /DROP=dummy. !ENDDEFINE. */////////////////// SET MPRINT=yes. !chart2 minnb=5 cats= age prog year. EXECUTE.