Date: Wed, 1 Feb 2006 13:57:59 -0500
Reply-To: Art@DrKendall.org
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Art Kendall <Art@DrKendall.org>
Organization: Social Research Consultants
Subject: Re: (simple) macro
In-Reply-To: <72A5DBEDEA97FA4A939074F676F6198B06035BD7@cscptomomxis001.csc.ad.gov.on.ca>
Content-Type: text/plain; charset=us-ascii; format=flowed
Perhaps something like this untested syntax will do it.
do repeat
v1 = var1_1 to var1_63
/ v2 = var2_1 to var2_63
/vnew = varnew_1 to varnew_63.
compute vnew=0.
if any(1, v1,v2) vnew=1.
end repeat.
Art
Art@DrKendall.org
Social Research Consultants
Patricia Cleland wrote:
>I have a small data set (97 cases, 63 variables measured twice). The value
>for each variable is 1 or 0. I want to create 63 new variables with the
>value of 1 if either of the original variables is 1. For example:
>
>IF (ANY(1, Var1_1, Var1_2)) Var1_1or2 = 1 .
>
>However, since there are 63 pairs of variables, I don't want to type the IF
>statement 63 times. This would seem like a perfect use for a macro, but I
>can't get it to work.
>
>Here's what I've written:
>
>
>DEFINE !COMPAREX (VAR1=!TOKENS(63)/VAR2=!TOKENS(63)/VAR3=!TOKENS(63))
>IF (ANY(1, !VAR1,!VAR2)) !VAR3 = 1 .
>!ENDDEFINE
>
>!COMPAREX VAR1= VAR1_1 VAR2_1 ...VAR63_1
> VAR2= VAR1_2 VAR2_2 ...VAR63_2
> VAR3= VAR1_1or2 VAR2_1or2 ...VAR63_1or2.
>
>Here's the error message that I get:
>
>
>
>>Error # 4007 in column 23. Text: Var2_1
>>The expression is incomplete. Check for missing operands, invalid
>>operators, unmatched parentheses or excessive string length.
>>This command not executed.
>>
>>
>
>Can anyone see what my error is? I'm on SPSS13.
>
>Pat
>
>
>
>
|