Date: Thu, 17 Jun 2004 16:04:40 +0200
Reply-To: fvillamayor-research@ferrergrupo.com
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Frederic Villamayor <fvillamayor-research@ferrergrupo.com>
Subject: Re: sample with given criteria
Content-Type: text/plain; charset="iso-8859-1"
Hi Adam,
This syntax does what you want. You can change the proportion of cases
into each combination of sex*education to obtain the desired sample (IF
$CASENUM LE ...).
*** This lines build a 10000 cases file, with equel number of individuals
on each combination of sex*education.
*** This would not affect the result if you apply the main lines of code
to your data.
NEW FILE.
INPUT PROGRAM.
- LOOP ID=1 TO 10000.
- END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
EXECUTE.
RANK
VARIABLES=id (A)
/NTILES (2) INTO sex
/PRINT=NO
/TIES=MEAN .
EXECUTE.
RANK
VARIABLES=id (A) BY sex
/NTILES (4) INTO educ
/PRINT=NO
/TIES=MEAN .
EXECUTE.
**** MAIN BODY.
*** Always set seed if you want to reproduce your procedure.
SET SEED = 152032.
COMPUTE aleat = UNIFORM (1).
COMPUTE filter = sex EQ 1 AND educ EQ 1.
SORT CASES BY filter (D) aleat (A).
*** Change the next line as desired.
IF $CASENUM LE 4 sample = 1.
EXECUTE.
COMPUTE filter = sex EQ 1 AND educ EQ 2.
SORT CASES BY filter (D) aleat (A).
*** Change the next line as desired.
IF $CASENUM LE 6 sample = 1.
EXECUTE.
COMPUTE filter = sex EQ 1 AND educ EQ 3.
SORT CASES BY filter (D) aleat (A).
*** Change the next line as desired.
IF $CASENUM LE 2 sample = 1.
EXECUTE.
COMPUTE filter = sex EQ 1 AND educ EQ 4.
SORT CASES BY filter (D) aleat (A).
*** Change the next line as desired.
IF $CASENUM LE 8 sample = 1.
EXECUTE.
COMPUTE filter = sex EQ 2 AND educ EQ 1.
SORT CASES BY filter (D) aleat (A).
*** Change the next line as desired.
IF $CASENUM LE 16 sample = 1.
EXECUTE.
COMPUTE filter = sex EQ 2 AND educ EQ 2.
SORT CASES BY filter (D) aleat (A).
*** Change the next line as desired.
IF $CASENUM LE 24 sample = 1.
EXECUTE.
COMPUTE filter = sex EQ 2 AND educ EQ 3.
SORT CASES BY filter (D) aleat (A).
*** Change the next line as desired.
IF $CASENUM LE 8 sample = 1.
EXECUTE.
COMPUTE filter = sex EQ 2 AND educ EQ 4.
SORT CASES BY filter (D) aleat (A).
*** Change the next line as desired.
IF case LE 32 sample = 1.
EXECUTE.
SELECT IF SAMPLE.
SORT CASES BY sample (D) sex educ (A).
CROSSTABS
/TABLES=educ BY sex BY sample
/FORMAT= AVALUE TABLES
/CELLS= COUNT .
Hope this helps
Frederic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Frederic Villamayor, BS
Departamento de Toxicología
CIDF Ferrer Grupo
Juan de Sada, 32
08028 - Barcelona
España
E-mail: fvillamayor-research@ferrergrupo.com
Tel: +34 935093236
Fax: +34 934112764
WWW: www.ferrergrupo.com
Adam Olszówka <adamolszowka@hotmail.com>
Enviado por: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
17.06.2004 14:48
Por favor, responda a Adam Olszówka
Para: SPSSX-L@LISTSERV.UGA.EDU
cc:
Asunto: sample with given criteria
Hi everybody,
I've got dataset with 10000 cases. Variables are: sex (codes:1,2) and
education (codes:1,2,3,4). I'm looking for syntax that would draw 100
cases
sample but with given criteria. Let's say:
sex=1 - 20
sex=2 - 80
and
education=1 - 20
education=2 - 30
education=3 - 10
education=4 - 40.
Any ideas how to do it or where I should look for it?
Thanks in advance,
Adam Olszowka