SPSS AnswerNet: Result Solution ID: 100008330 Product: SPSS Base Version: O/S: Question Type: Syntax/Batch/Scripting Question Subtype: Macro Facility Title: Getting repeated subsamples from a dataset Description: Q. I would like to get a subsample of cases so that I can get the mean of that subsample. I would like to this repeatedly so that I get the means of a number of subsamples. This way, I can prove the central tendency theorem. Is there a way that I can do this? A. Yes, there is. By using a macro, you can repeatedly pull a subsample of cases and get the mean of that subsample. Below is an example of how this can be done. Using the COUNTRY.SAV file that is found in the Norusis "SPSS Guide to Data Analysis" manual, we pull 30 samples of 10 cases each, and we get the mean and standard deviation of the GDP variable for those samples. DEFINE repsamp (). !DO !doover = 1 !TO 30. USE ALL. do if $casenum = 1. compute #s_$_1=10. compute #s_$_2=122. end if. do if #s_$_2 > 0. compute filter_$ = uniform(1)* #s_$_2 < #s_$_1. compute #s_$_1 = #s_$_1 - filter_$. compute #s_$_2 = #s_$_2 - 1. else. compute filter_$ = 0. end if. VARIABLE LABEL filter_$ '10 from the first 122 cases (SAMPLE)'. FORMAT filter_$ (f1.0). FILTER BY filter_$. DESCRIPTIVES VARIABLES=gdp /STATISTICS=MEAN STDDEV . !DOEND. !ENDDEFINE. repsamp.