*Take a random sample. get file="Y:\SPSS\data\employee data.sav". dataset name ds1. SAMPLE 0.10. *Approximate n, delete unwanted cases. frequencies variables=jobcat. SAMPLE 10 from 474. *Exact n, delete unwanted*. frequencies variables=jobcat. get file="Y:\SPSS\data\employee data.sav". dataset name ds1. compute filter_$=(uniform(1)<=.10). *Approximate n, filter out the unwanted. filter by filter_$. descriptives salary. filter off. descriptives salary. * Filtering by an exact sample size is more complicated. * One approach is this. compute rn = rv.uniform(0,1). execute. sort cases by rn . compute flag = ($casenum <= 40) . execute. filter by flag. frequencies variables = gender. * A more elegant approach just passes once through the data set but requires more complicated use of the language. do if $casenum = 1. compute pick = 40 . compute total = 474 . leave pick total. end if. do if total > 0. compute flag = (rv.uniform(0,1)*total < pick). compute pick = pick - flag. compute total = total - 1. else. compute flag = 0. end if. filter by flag . execute . frequencies variables = gender .