*QUESTION: I would like a macro to show variability given a fixed sample size (lets say 100), but changing the number of samples that are taken into account. I mean, I would like to show a salary mean calculated as the mean of 5 samples, 10 samples, ..., 50 samples (yes, I am trying to show some properties of the sampling distribution, central limit theorem, etc. etc.). * SOLUTION posted to SPSSX-L by Raynald Levesque rlevesque@videotron.ca on 2001/08/09. SET MPRINT=yes. * -------------------DEFINE MACRO ---------------------------------------------. DEFINE !sample(myvar !TOKENS(1) /size !TOKENS(1) /nbsampl !CMDEND) /* myvar = the variable of interest (here we want the mean of salary) */ /* nbsampl = number of samples */ /* size = the size of each samples */. !LET !first='1' !DO !ss !IN (!nbsampl) !DO !count = 1 !TO !size. GET FILE='c:\\Program Files\\SPSS\\employee data.sav'. COMPUTE draw=uniform(1). SORT CASES BY draw. N OF CASES !ss. COMPUTE samplenb=!count. COMPUTE ss=!ss. AGGREGATE /OUTFILE=* /BREAK=samplenb /!myvar = MEAN(!myvar) /ss=FIRST(ss). !IF (!first !NE '1') !THEN ADD FILES /FILE=* /FILE='c:\\temp\\sample.sav'. !IFEND SAVE OUTFILE='c:\\temp\\sample.sav'. !LET !first='0' !DOEND. !DOEND. VARIABLE LABEL ss !QUOTE(!CONCAT('Number of Samples of size ',!size)). EXAMINE VARIABLES=salary BY ss /PLOT=BOXPLOT/STATISTICS=NONE/NOTOTAL /MISSING=REPORT. !ENDDEFINE. * ----------------END OF MACRO ----------------------------------------------. * Call macro (parameters are number of samples (here 5 10 25 35 50) and size of sample (here 10). * Thus 5 samples of size 10. * Thus 10 samples of size 10, etc. !sample myvar=salary size=10 nbsampl=5 10 25 35 50.