=========================================================================
Date: Wed, 5 Jul 2006 17:20:15 +0200
Reply-To: Frederic Villamayor Forcada <fvillamayor-research@ferrergrupo.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Frederic Villamayor Forcada <fvillamayor-research@ferrergrupo.com>
Subject: Re: Generating all posibble binary patterns for m variables
In-Reply-To: <17210038921.20060705155505@terra.es>
Content-Type: text/plain; charset="ISO-8859-1"
Marta:
I think I've got it!
INPUT PROGRAM.
LOOP I=0 TO (2**15)-1.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.
FORMATS I(N5).
NUMERIC V0 to V14 (F3) coc0 TO coc15(f5).
STRING VV0 to VV14(a1).
VECTOR V=V0 TO V14
/coc=coc0 TO coc15
/VV=VV0 to VV14.
LOOP X=15 TO 1 BY -1.
- DO IF i<2**x AND i>=2**(x-1).
- COMPUTE coc(x+1)=i.
- LOOP Y=X to 1 by -1.
- COMPUTE COC(y)=trunc(COC(y+1)/2).
- COMPUTE v(y) = mod(coc(y+1),2).
- COMPUTE vV(y) = STRING(mod(coc(y+1),2),F1).
- END LOOP.
- end if.
END LOOP.
IF I=0 V0=0.
IF I=0 Vv0='0'.
execute.
STRING BIN(a15).
compute bin= lpad(rtrim(CONCAT(VV0 to VV14)),15,"0").
EXECUTE.
numeric x1 to x15 (F3).
VECTOR XX=X1 to X15.
LOOP X=1 TO 15.
compute XX(X)=NUMBER(SUBSTR(BIN,x,1),F1).
END LOOP.
execute.
Surely this syntax will need some debugging in otder to optimize it. But
you will get the variables you need!
Happy holidays!
Frederic.
%%%%%%%%%%%%%%%%%%%%%%%
Frederic Villamayor
Unitat de Bioestadística
Àrea de Desenvolupament Preclínic
CIDF Ferrer Grupo
Juan de Sada, 32
08028 - Barcelona
Espanya
E-mail: fvillamayor-research@ferrergrupo.com
Tel: +34 935093236
Fax: +34 934112764
WWW: www.ferrergrupo.com
%%%%%%%%%%%%%%%%%%%%%%%
"Sanity is not statistical"