variable construction

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

variable construction

P.van Groenestijn
Dear List Members,

I wonder how to make a new variables with the sum as long as previous
variables have a score 1.
To make things clear I give an example.

data list free / text(a5) v1 v2 v3 v4 v5. res1 res2 res3 res4 res5
begin data
00-11 0 0 . 1 1 0 0 0 1 2
100-1 1 0 0 . 1 1 0 0 0 1
11--0 1 1 . . 0 1 2 0 0 1
end data.

In this file the original string variable (text) is already converted
into five nummeric variables (v1 to v5).
I would like to make the result variables (res1 to res5) with some syntax.
How can I do this?

Any help will be highly appreciated!

Regards,
Pieter van Groenestijn

--
RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email: [hidden email]
hp: http://www.ru.nl/fsw/rtog/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: variable construction

John F Hall
I think you need something like:
 
count
   vcount = v1 to v5 (1)
  /rescount = res1 to res 5 (1) .
freq vcount rescount .
----- Original Message -----
Sent: Wednesday, July 07, 2010 5:45 PM
Subject: variable construction


Dear List Members,

I wonder how to make a new variables with the sum as long as previous
variables have a score 1.
To make things clear I give an example.

data list free / text(a5) v1 v2 v3 v4 v5. res1 res2 res3 res4 res5
begin data
00-11 0 0 . 1 1 0 0 0 1 2
100-1 1 0 0 . 1 1 0 0 0 1
11--0 1 1 . . 0 1 2 0 0 1
end data.

In this file the original string variable (text) is already converted
into five nummeric variables (v1 to v5).
I would like to make the result variables (res1 to res5) with some syntax.
How can I do this?

Any help will be highly appreciated!

Regards,
Pieter van Groenestijn

--
RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email: [hidden email]
hp: http://www.ru.nl/fsw/rtog/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

Reply | Threaded
Open this post in threaded view
|

Re: variable construction

Ruben Geert van den Berg
In reply to this post by P.van Groenestijn
Dear Pieter,
 
I think the following syntax should work. I called the new variables t1-t5 (so I could compare them to res1-res5).
 
data list free / text(a5) v1 v2 v3 v4 v5 res1 res2 res3 res4 res5.
begin data
00-11 0 0 '' 1 1 0 0 0 1 2
100-1 1 0 0 '' 1 1 0 0 0 1
11--0 1 1 '' '' 0 1 2 0 0 1
end data.
 
vector v=v1 to v5/t(5).
compute t(1)=v(1).
loop #i=2 to 5.
do if v(#i)=0 or mis(v(#i))=1.
compute t(#i)=0.
else.
compute t(#i)=v(#i)+t(#i-1).
end if.
end loop.
 
execute.
 
HTH,


Ruben van den Berg
Consultant Models & Methods
TNS NIPO
Email: [hidden email]
Mobiel: +31 6 24641435
Telefoon: +31 20 522 5738
Internet: www.tns-nipo.com



 

> Date: Thu, 8 Jul 2010 09:54:18 +0200
> From: [hidden email]
> To: [hidden email]
> Subject: Re: variable construction
>
> Hallo Ruben,
> Je hebt helemaal gelijk!
>
> groet,
> Pieter van Groenestijjn
>
>
>
> RadboudUniversiteit Nijmegen
> Faculteit Sociale Wetenschappen
> Research Technische OndersteuningsGroep
> Thomas van Aquinostraat 4.00.51
> tel: 024-3612035
> fax: 024-3612351
> email: [hidden email]
> hp: http://www.ru.nl/fsw/rtog/
>
>
>
> Ruben van den Berg wrote:
> > Beste Pieter, moet res5 voor de laatste record niet 0 zijn? Of begrijp
> > ik dan de vraag niet goed?
> >
> > *Ruben van den Berg*
> > *Consultant Models & Methods*
> > TNS NIPO
> > Email: [hidden email]
> > Mobiel: +31 6 24641435
> > Telefoon: +31 20 522 5738
> > Internet: www.tns-nipo.com
> >
> >
> >
> >
> > > Date: Wed, 7 Jul 2010 17:45:25 +0200
> > > From: [hidden email]
> > > Subject: variable construction
> > > To: [hidden email]
> > >
> > > Dear List Members,
> > >
> > > I wonder how to make a new variables with the sum as long as previous
> > > variables have a score 1.
> > > To make things clear I give an example.
> > >
> > > data list free / text(a5) v1 v2 v3 v4 v5. res1 res2 res3 res4 res5
> > > begin data
> > > 00-11 0 0 . 1 1 0 0 0 1 2
> > > 100-1 1 0 0 . 1 1 0 0 0 1
> > > 11--0 1 1 . . 0 1 2 0 0 1
> > > end data.
> > >
> > > In this file the original string variable (text) is already converted
> > > into five nummeric variables (v1 to v5).
> > > I would like to make the result variables (res1 to res5) with some
> > syntax.
> > > How can I do this?
> > >
> > > Any help will be highly appreciated!
> > >
> > > Regards,
> > > Pieter van Groenestijn
> > >
> > > --
> > > RadboudUniversiteit Nijmegen
> > > Faculteit Sociale Wetenschappen
> > > Research Technische OndersteuningsGroep
> > > Thomas van Aquinostraat 4.00.51
> > > tel: 024-3612035
> > > fax: 024-3612351
> > > email: [hidden email]
> > > hp: http://www.ru.nl/fsw/rtog/
> > >
> > > =====================
> > > To manage your subscription to SPSSX-L, send a message to
> > > [hidden email] (not to SPSSX-L), with no body text except the
> > > command. To leave the list, send the command
> > > SIGNOFF SPSSX-L
> > > For a list of commands to manage subscriptions, send the command
> > > INFO REFCARD
> >
> > ------------------------------------------------------------------------
> > New Windows 7: Simplify what you do everyday. Find the right PC for
> > you. <http://windows.microsoft.com/shop>


Express yourself instantly with MSN Messenger! MSN Messenger