Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to assign same values to multiple variables in syntax?

681 views
Skip to first unread message

Filip Van Droogenbroeck

unread,
Dec 21, 2010, 8:18:47 AM12/21/10
to
Hi everybody,

Is there any way in spss to assign one value to multiple variables at
once in a single statements?

Something along these lines (pseudocode):

if(x<10) num1=num2=num3=num4=1.

Goal is that all variables num* have the value 1 when x is smaller
than 10.

Kind regards,
Filip Van Droogenbroeck

Art Kendall

unread,
Dec 21, 2010, 8:31:50 AM12/21/10
to
something like this untested syntax should do it.
Of course be careful that you are not writing over original data.

do if x lt 10.
do repeat num= num1 to num4.
compute num=1.
end repeat.
*this is where you might put what to put in num otherwise.
end if.

Art Kendall
Social Research Consultants.

Rich Ulrich

unread,
Dec 21, 2010, 4:51:48 PM12/21/10
to
On Tue, 21 Dec 2010 05:18:47 -0800 (PST), Filip Van Droogenbroeck
<filip.van.d...@gmail.com> wrote:

>Hi everybody,
>
>Is there any way in spss to assign one value to multiple variables at
>once in a single statements?

The one provision that I know of for multiple assignments
is useful for initializing variables. I've used it especially often
after creating a new VECTOR ...

RECODE var1, var10 to var11(ELSE= 0).


>
>Something along these lines (pseudocode):
>
>if(x<10) num1=num2=num3=num4=1.
>
>Goal is that all variables num* have the value 1 when x is smaller
>than 10.

... but, so far as I know, the RECODE is always unconditional -- It
cannot depend on an IF or DO IF.


--
Rich Ulrich

Filip Van Droogenbroeck

unread,
Dec 22, 2010, 9:07:29 AM12/22/10
to
On 21 dec, 22:51, Rich Ulrich <rich.ulr...@comcast.net> wrote:
> On Tue, 21 Dec 2010 05:18:47 -0800 (PST), Filip Van Droogenbroeck
>
> <filip.van.droogenbro...@gmail.com> wrote:
> >Hi everybody,
>
> >Is there any way in spss to assign one value to multiple variables at
> >once in a single statements?
>
> The one provision that I know of for multiple assignments
> is useful for initializing variables.  I've used it especially often
> after creating a new VECTOR ...
>
> RECODE  var1, var10 to var11(ELSE= 0).
>
Tnx for the answers.
Rich I tried te following in spss 19:

do if (v50x10=1).
recode v50x01 v50x02 v50x03 v50x04 v50x05 v50x06 v50x07 v50x08 v50x09
(1=8) (else = copy).
end if.

this works, apparently the recode command can be conditioned in
spss19.

kind regards,
Filip Van Droogenbroeck

JKPeck

unread,
Dec 22, 2010, 11:04:41 AM12/22/10
to
On Dec 22, 7:07 am, Filip Van Droogenbroeck

Recode can be governed by conditionals such as DO IF as far back as at
least V15 and probably much earlier.

Regards,
Jon Peck

0 new messages