The CREATE command can construct a new variable whose values are
the cumulative sums of another variable (CSUM). You could do that and
then just COMPUTE a 0/1 variable from that.
HTH,
Jon Peck
From: SPSSX(r) Discussion
[mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Hartman, Lacey (MDH)
Sent: Wednesday, October 21, 2009 3:46 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: [SPSSX-L]
I
need to assign a dummy variable equal to 1 until a weighted proportion for a
subset of cases reaches a certain cutoff. So, for example, I want to
assign records as SI=1 until the proportion of (sum of weights where SI=1 for a
given class)/(sum of weights for all records in a given class)=0.13.
I
have already used the aggregate function to assign the sum of weights to each
record depending on what class they are in, but I’m trying to figure out
a way to use a loop statement to create the numerator that I need above so that
the loop knows when to stop. But it doesn’t seem that aggregate
works within the LOOP END LOOP function, I tried this code:
loop
if (indic=1 & sizemore1=1 & prop1<.0875).
compute
si=1.
aggregate
/break
si
/sumnum1=sum(perwt06f).
do
if si=1.
compute
prop1=sumnum1/sumwt1.
end
if.
end
loop.
Would
appreciate any advice about a better approach.
Thanks!