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.
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).
do if si=1.
Would appreciate any advice about a better approach.