Date: Tue, 27 Nov 2001 12:26:05 -0500 Jessica Kenty "SPSSX(r) Discussion" Jessica Kenty Re: Combinations of Numbers text/plain; charset="iso-8859-1"

Thanks to all who offered solutions to my syntax problem! Many people requested that I post any solutions I received, so I have included (below) my original e-mail & the 3 solutions provided to me. Jessica ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Jessica Kenty Research Assistant Assets & Educational Inequality Project Northeastern University Boston, MA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MY ORIGINAL QUESTION: I am trying to come up with a fast way to find all possible combinations of values for each case using the following:

Variable Name Variable Values v84 0, 1, or 2 v89 0, 1, or 2 v94 0, 1, or 2 v99 0, 1, or 2

For example, one possible case might have: 0, 0, 0, 1. Another case might have: 1, 0, 0, 1. And so on... To do this by hand is extremely time consuming. Anyone know a program to use or website in which you can punch in this info. and get some 4 digit combinations back? Or can SPSS do this?

The end result for me is to come up with a series of IF statements to use in a COMPUTE command. Basically:

COMPUTE test=0. If (v84=0 AND v89=0 AND v94=0 AND v99=0) test=1. If (v84=0 AND v89=1 AND v94=0 AND V99=1) test=2. . . . EXECUTE.

If someone knows how to do this in SPSS also, that would be prefered! Thanks in advance. Jessica

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SOLUTION # 1 (RAYNALD LEVESQUE)

Hi Jessica and listmembers,

what you describe can be done using a macro or a script. However I wonder if the following simple (2 lines) solution would not meet your needs:

* Create some date for illustration purposes. INPUT PROGRAM. LOOP #=1 TO 100. COMPUTE v84=TRUNC(UNIFORM(3)). COMPUTE v89=TRUNC(UNIFORM(3)). COMPUTE v94=TRUNC(UNIFORM(3)). COMPUTE v99=TRUNC(UNIFORM(3)). END CASE. END LOOP. END FILE. END INPUT PROGRAM.

* Next 2 lines are a solution. COMPUTE test1=v84*1000 + v89*100 + v94*10 + v99. AUTORECODE test1 /INTO test.

The variable "test" then contains values ranging from 1 to the number of existing combinations (of the 3 values times 4 variables) in the data file. Moreover, the value labels of the test variable contain the corresponding value of test1.

HTH Raynald Levesque rlevesque@videotron.ca Visit My SPSS Pages: http://pages.infinit.net/rlevesqu/index.htm

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SOLUTION #2 (ARTHUR KENDALL) KendallA@GAO.GOV If you are interested in the sets that actually occur you could try something like this.

numeric permu (n4), compute permu= (v84 * 10**3) + (v89 * 10**2) + (v94 * 10**1) + (v99 * 10 **0). to get the number that actually occur autorecode permu /into permu2. and see what the highest value of permu2 is.

if you want just the total number of possibilities it is 3 **4 or 81.

if you want to generate a file with one case per possibility new file. input program. loop #i84 = 0 to 2. loop #i89 = 0 to 2. loop #i94 = 0 to 2. loop #i99 = 0 to 2.

compute permu3= (#i84 * 10**3) + (#i89 * 10**2) + (#i94 * 10**1) + (#i99 * 10 **0). end case.

end loop. end loop. end loop. end loop.

end file. end input program. formats permu3(n4). execute. cache.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SOLUTION #3 (J. RUSSELL) J.Russell@sheffield.ac.uk

You could try this

compute total=v84+3* v89+9*v94+27* V99. Value labels total 0 '0000' 1 '1000' 2 '2000' 3 '0100' 4 '1100' 5 '2100' 6 ''0200' 7 '1200' 8 '2200' 9 '0010' 10 '1010' 11 '2010' 12 '0110' 13 '1110' 14 '2110' 15 ''0210' 16 '1210' 17 '2210' 18 '0020' 19 '1020' 20 '2020' 21 '0120' 22 '1120' 23 '2120' 24 ''0220' 25 '1220' 26 '2220' 27 '0001' 28 '1001' 29 '2001' 30 '0101' 31 '1101' 32 '2101' 33 ''0201' 34 '1201' 35 '2201' 36 '0011' 37 '1011' 38 '2011' 39 '0111' 40 '1111' 41 '2111' 42 ''0211' 43 '1211' 44 '2211' 45 '0021' 46 '1021' 47 '2021' 48 '0121' 49 '1121' 50 '2121' 51 ''0221' 52 '1221' 53 '2221' 54 '0002' 55 '1002' 56 '2002' 57 '0102' 58 '1102' 59 '2102' 60 ''0202' 61 '1202' 62 '2202' 63 '0012' 64 '1012' 65 '2010' 66 '0112' 67 '1112' 68 '2112' 69 ''0212' 70 '1212' 71 '2212' 72 '0022' 73 '1022' 74 '2022' 75 '0122' 76 '1122' 77 '2122' 78 ''0222' 79 '1222' 80 '2222'. Autorecode total /into final.

Jean

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