LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2006)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 5 Jul 2006 12:46:53 +0200
Reply-To:     Marta García-Granero
              <biostatistics@terra.es>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Marta García-Granero
              <biostatistics@terra.es>
Organization: Asesoría Bioestadística
Subject:      Generating all posibble binary patterns for m variables
Content-Type: text/plain; charset=ISO-8859-15

Hi list

I'm stuck in the middle of an "impossible?" problem. I need to create datasets with the following characteristics:

If nvars=3: x1 x2 x3 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 1 0 1 0 1 1 1 1 1 Total number of patterns:8

If nvars=4: x1 x2 x3 x4 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 1 0 1 0 1 0 0 1 0 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 1 1 0 1 1 0 1 1 1 1 1 1 Total number of patters:16

If nvars=5: x1 x2 x3 x4 x5 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 1 0 1 0 1 1 0 0 1 1 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 1 1 1 1 1 1 Total number of patters:32

General rule: the patterns are all the posible combinations of 0/1 values (total possible patterns: 2^nvars).

I would ideally need a MACRO to compute them for up to 15 variables.

Years ago I did it with a BASIC program (for eight variables), but I had the advantage of being able to extract bits from a byte, and the code was very easy: computing with a loop numbers form 1 to 256, and extracting eight variables with the value of every bit that formed the byte.

I don't know how to handle it with SPSS :(

No need to hurry, tomorrow I'm leaving for 12 days (trying again the also impossible task of getting a tan, I happen to have a very low phototype).

Regards

Marta


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