Date: Fri, 15 Jul 2011 09:47:55 -0700
Reply-To: David Marso <david.marso@gmail.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: David Marso <david.marso@gmail.com>
Subject: Re: Syntax for SAMPLE
In-Reply-To: <23380822E17E3245A4E9FC9A63E2BA13B01C1C@CEXMB003.nmes.lcl>
Content-Type: text/plain; charset=us-ascii
I would go at it quite differently.
I am assuming you know the counts for each group? No need in this case to
know N per group.
say
GROUPCODE DesiredCount
1 10
2 5
3 ..
...
7 5
..
9 10
Create a small SPSS data file containing these 2 variables and values
save it as "<somevaliddirpath>COUNTS.SAV".
<somevaliddirpath> being something like "C:\Documents\SPSSData\SomeProject\"
.
Grab your data file.
GET FILE'masterfileblahblah.sav".
COMPUTE @SCRAMBLER=UNIFORM(1).
SORT CASES BY GROUPCODE @SCRAMBLER.
MATCH FILES
/ FILE *
/ TABLE "<somevaliddirpath>COUNTS.SAV"
/ BY GROUPCODE.
IF $CASENUM=1 OR LAG(GROUPCODE) NE GROUPCODE GPCounter=1.
IF MISSING( GPCounter) GPCounter=LAG(GPCounter+1).
COMPUTE Use_This_Case=GPCounter LE DesiredCount .
FILTER BY Use_This_Case.
Gregory, Cindy, PED wrote:
>
> I must draw fixed count random samples from different groups and I am
> looking for more efficient code. For example:
>
> DO IF GROUPCODE=7.
> SAMPLE 5 FROM 32.
> (write to outfile)
> END IF.
>
> DO IF GROUPCODE=9.
> SAMPLE 10 from 93.
> (write to outfile)
> END IF.
>
> I have tried using DO REPEAT, but the SAMPLE command doesn't let me use a
> function or macro variable in place of the numbers. I look to your wisdom
> and tutelage - any help appreciated.
>
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Syntax-for-SAMPLE-tp4591268p4591398.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD