```Date: Tue, 3 Jul 2007 11:42:46 -0400 Reply-To: Richard Ristow Sender: "SPSSX(r) Discussion" From: Richard Ristow Subject: Re: How to generate 1000 samples? Comments: To: Gene Maguin Comments: cc: Sien Chieh Tay In-Reply-To: <002101c7bd7b\$4ceb8900\$2345cd80@ssw.buffalo.edu> Content-Type: text/plain; charset="us-ascii"; format=flowed Gene - At 10:06 AM 7/3/2007, you wrote: >Ok, now I understand much better what you want to do. This should >work. > >INPUT PROGRAM. >VECTOR FILTER(100). >+ LOOP SAMPLE=1 TO 100. >+ LOOP #Case = 1 to 1000. >+ COMPUTE X = RV.NORMAL(0,1). >* HERE IS THE KEY STATEMENT. 10 IS THE NUMBER OF CASES TO BE >SELECTED. >+ IF (SAMPLE LE 10) FILTER(SAMPLE)=1. >+ END CASE. >+ END LOOP. >+ END LOOP. >+ END FILE. >END INPUT PROGRAM. I'm not quite clear about the problem, but is what this gives you, what you had in mind? It gives 100,000 cases, which is a reasonable interpretation of "100 samples of 1000". All have the variable X, drawn from the normal distribution. Variable SAMPLE has values in 100 cases: 1 in case 1, 2 in case 1001, 3 in case 2001, etc. You likely wanted SAMPLE to be 1 in cases 1-1000, 2 in cases 1001-2000, etc., and ran into a known glitch with LOOP and INPUT PROGRAM. If you specify "LEAVE" for SAMPLE, you'll get the above. I'm not sure about the FILTERxxx variables. You logic will never populate any but the first 10 of those. Those 10 are essentially surrogates for SAMPLE: with SAMPLE fully populated, FILTER1 is 1 in the 1,000 cases of the first sample, system-missing otherwise; FILTER1 is 1 in the 1,000 cases of the second sample, system-missing otherwise; etc. If you want to mark 10 cases in each sample, which *sounds* like what was wanted, you can use a single variable FILTER, and set it to 1 if your counter #Case is 10 or less, 0 otherwise; that marks the first 10. Or of course there are ways of distributing FILTER randomly through the samples, probably by k/n logic; but, as you say, there's no obvious reason for doing that. That gives something like this, though I'm still not sure it's what's desired. SPSS 15 draft output (WRR:not saved separately): INPUT PROGRAM. + LOOP SAMPLE=1 TO 100. . LEAVE SAMPLE. . FORMATS SAMPLE(F4). . NUMERIC FILTER(F2). + LOOP #Case = 1 to 1000. + COMPUTE X = RV.NORMAL(0,1). * HERE IS THE KEY STATEMENT. 10 IS THE NUMBER OF CASES TO BE SELECTED. * ----- IF (SAMPLE LE 10) FILTER(SAMPLE)=1. ---- . . RECODE #Case (1 THRU 10 = 1) (ELSE = 0) INTO FILTER. + END CASE. + END LOOP. + END LOOP. + END FILE. END INPUT PROGRAM. LIST FORMAT = NUMBERED/CASES FROM 1 TO 15. List |-----------------------------|---------------------------| |Output Created |03-JUL-2007 11:40:08 | |-----------------------------|---------------------------| SAMPLE FILTER X 1 1 1 -1.45 2 1 1 1.51 3 1 1 -.86 4 1 1 1.08 5 1 1 1.19 6 1 1 -.59 7 1 1 -.26 8 1 1 .65 9 1 1 -1.01 10 1 1 -.62 11 1 0 1.39 12 1 0 .66 13 1 0 -.52 14 1 0 .12 15 1 0 .81 Number of cases read: 15 Number of cases listed: 15 CROSSTABS /TABLES=SAMPLE BY FILTER /FORMAT= AVALUE TABLES /CELLS= COUNT /COUNT ROUND CELL . Crosstabs |-----------------------------|---------------------------| |Output Created |03-JUL-2007 11:40:08 | |-----------------------------|---------------------------| Case Processing Summary [suppressed - no missing data] SAMPLE * FILTER Crosstabulation Count |------|---|----------|------| | | |FILTER |Total | | | |-----|----|------| | | |0 |1 |0 | |------|---|-----|----|------| |SAMPLE|1 |990 |10 |1000 | | |---|-----|----|------| | |2 |990 |10 |1000 | | |---|-----|----|------| | |3 |990 |10 |1000 | | |---|-----|----|------| | |4 |990 |10 |1000 | | |---|-----|----|------| | |5 |990 |10 |1000 | | |---|-----|----|------| | |6 |990 |10 |1000 | | |---|-----|----|------| | |7 |990 |10 |1000 | | |---|-----|----|------| | |8 |990 |10 |1000 | | |---|-----|----|------| | |9 |990 |10 |1000 | | |---|-----|----|------| | |10 |990 |10 |1000 | | |---|-----|----|------| | |11 |990 |10 |1000 | | |---|-----|----|------| | |12 |990 |10 |1000 | | |---|-----|----|------| | |13 |990 |10 |1000 | | |---|-----|----|------| | |14 |990 |10 |1000 | | |---|-----|----|------| | |15 |990 |10 |1000 | | |---|-----|----|------| | |16 |990 |10 |1000 | | |---|-----|----|------| | |17 |990 |10 |1000 | | |---|-----|----|------| | |18 |990 |10 |1000 | | |---|-----|----|------| | |19 |990 |10 |1000 | | |---|-----|----|------| | |20 |990 |10 |1000 | | |---|-----|----|------| | |21 |990 |10 |1000 | | |---|-----|----|------| | |22 |990 |10 |1000 | | |---|-----|----|------| | |23 |990 |10 |1000 | | |---|-----|----|------| | |24 |990 |10 |1000 | | |---|-----|----|------| | |25 |990 |10 |1000 | | |---|-----|----|------| | |26 |990 |10 |1000 | | |---|-----|----|------| | |27 |990 |10 |1000 | | |---|-----|----|------| | |28 |990 |10 |1000 | | |---|-----|----|------| | |29 |990 |10 |1000 | | |---|-----|----|------| | |30 |990 |10 |1000 | | |---|-----|----|------| | |31 |990 |10 |1000 | | |---|-----|----|------| | |32 |990 |10 |1000 | | |---|-----|----|------| | |33 |990 |10 |1000 | | |---|-----|----|------| | |34 |990 |10 |1000 | | |---|-----|----|------| | |35 |990 |10 |1000 | | |---|-----|----|------| | |36 |990 |10 |1000 | | |---|-----|----|------| | |37 |990 |10 |1000 | | |---|-----|----|------| | |38 |990 |10 |1000 | | |---|-----|----|------| | |39 |990 |10 |1000 | | |---|-----|----|------| | |40 |990 |10 |1000 | | |---|-----|----|------| | |41 |990 |10 |1000 | | |---|-----|----|------| | |42 |990 |10 |1000 | | |---|-----|----|------| | |43 |990 |10 |1000 | | |---|-----|----|------| | |44 |990 |10 |1000 | | |---|-----|----|------| | |45 |990 |10 |1000 | | |---|-----|----|------| | |46 |990 |10 |1000 | | |---|-----|----|------| | |47 |990 |10 |1000 | | |---|-----|----|------| | |48 |990 |10 |1000 | | |---|-----|----|------| | |49 |990 |10 |1000 | | |---|-----|----|------| | |50 |990 |10 |1000 | | |---|-----|----|------| | |51 |990 |10 |1000 | | |---|-----|----|------| | |52 |990 |10 |1000 | | |---|-----|----|------| | |53 |990 |10 |1000 | | |---|-----|----|------| | |54 |990 |10 |1000 | | |---|-----|----|------| | |55 |990 |10 |1000 | | |---|-----|----|------| | |56 |990 |10 |1000 | | |---|-----|----|------| | |57 |990 |10 |1000 | | |---|-----|----|------| | |58 |990 |10 |1000 | | |---|-----|----|------| | |59 |990 |10 |1000 | | |---|-----|----|------| | |60 |990 |10 |1000 | | |---|-----|----|------| | |61 |990 |10 |1000 | | |---|-----|----|------| | |62 |990 |10 |1000 | | |---|-----|----|------| | |63 |990 |10 |1000 | | |---|-----|----|------| | |64 |990 |10 |1000 | | |---|-----|----|------| | |65 |990 |10 |1000 | | |---|-----|----|------| | |66 |990 |10 |1000 | | |---|-----|----|------| | |67 |990 |10 |1000 | | |---|-----|----|------| | |68 |990 |10 |1000 | | |---|-----|----|------| | |69 |990 |10 |1000 | | |---|-----|----|------| | |70 |990 |10 |1000 | | |---|-----|----|------| | |71 |990 |10 |1000 | | |---|-----|----|------| | |72 |990 |10 |1000 | | |---|-----|----|------| | |73 |990 |10 |1000 | | |---|-----|----|------| | |74 |990 |10 |1000 | | |---|-----|----|------| | |75 |990 |10 |1000 | | |---|-----|----|------| | |76 |990 |10 |1000 | | |---|-----|----|------| | |77 |990 |10 |1000 | | |---|-----|----|------| | |78 |990 |10 |1000 | | |---|-----|----|------| | |79 |990 |10 |1000 | | |---|-----|----|------| | |80 |990 |10 |1000 | | |---|-----|----|------| | |81 |990 |10 |1000 | | |---|-----|----|------| | |82 |990 |10 |1000 | | |---|-----|----|------| | |83 |990 |10 |1000 | | |---|-----|----|------| | |84 |990 |10 |1000 | | |---|-----|----|------| | |85 |990 |10 |1000 | | |---|-----|----|------| | |86 |990 |10 |1000 | | |---|-----|----|------| | |87 |990 |10 |1000 | | |---|-----|----|------| | |88 |990 |10 |1000 | | |---|-----|----|------| | |89 |990 |10 |1000 | | |---|-----|----|------| | |90 |990 |10 |1000 | | |---|-----|----|------| | |91 |990 |10 |1000 | | |---|-----|----|------| | |92 |990 |10 |1000 | | |---|-----|----|------| | |93 |990 |10 |1000 | | |---|-----|----|------| | |94 |990 |10 |1000 | | |---|-----|----|------| | |95 |990 |10 |1000 | | |---|-----|----|------| | |96 |990 |10 |1000 | | |---|-----|----|------| | |97 |990 |10 |1000 | | |---|-----|----|------| | |98 |990 |10 |1000 | | |---|-----|----|------| | |99 |990 |10 |1000 | | |---|-----|----|------| | |100|990 |10 |1000 | |------|---|-----|----|------| |Total |99000|1000|100000| |----------|-----|----|------| has the normally distributed variable >There may be a much more elegant way to do it but I don't know what it >is. >Let me pose this question: Why not just take the first m cases in the >set of >1000 as your 'selected' cases. There is nothing special about them. >-- >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.476 / Virus Database: 269.9.14/885 - Release Date: >7/3/2007 10:02 AM ```

Back to: Top of message | Previous page | Main SPSSX-L page