assigning string variable value to subsequent cases

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

assigning string variable value to subsequent cases

Muir Houston-3
I have a dataset (160k cases) which has a string variable for household ID (HiD1) and this may have multiple cases (total members of household varies). Now I have second string variable identifying the travel to work area (TtW1) of groups of these households.

However only the first case in HiD1 has the value of TtW1 - if there are multiple members of the household their value for TtW1 is blank. What I want to do is assign the value of TtW1 to the multiple members of households indentified by multiple cases in HiD1

In the example the first two cases in HiD1 have only one member in that household; while the third case has three members - but only first has value for TtW1 assigned


Example
HiD1 TtW1
6800683 E30000093
6800716 E30000093
6800782 E30000093
6800782
6800782
7154600 E30000093
7154624 E30000093
8795789 E30000175
8795789
8795789
8899000 E30000175
8975461 E30000175
8975461
8975461
...... .......

I have had a look at some of the syntax on SPSS tools but unable to find what I need

Any suggestions of a starting point gratefully received but do not have Python skills


Cheers
Muir


Muir Houston, HNC, BA (Hons), M.Phil., PhD, FHEA
College of Social Sciences Ethics Officer
Social Justice, Place and Lifelong Education Research
School of Education
University of Glasgow
0044+141-330-4699

Silver bullet or red herring? New evidence on the place of aspirations in education
R3L+ Project - Adult education in the light of the European Quality Strategy
http://www.learning-regions.net/

GINCO Project - Grundtvig International Network of Course Organisers
http://www.ginconet.eu/

THEMP - Tertiary Higher Education for People in Mid Life
http://themp.eu/ 
 

=====================
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: assigning string variable value to subsequent cases

David Marso
Administrator
Look up IF and LAG in the fine manual!
--
Muir Houston-3 wrote
I have a dataset (160k cases) which has a string variable for household ID (HiD1) and this may have multiple cases (total members of household varies). Now I have second string variable identifying the travel to work area (TtW1) of groups of these households.

However only the first case in HiD1 has the value of TtW1 - if there are multiple members of the household their value for TtW1 is blank. What I want to do is assign the value of TtW1 to the multiple members of households indentified by multiple cases in HiD1

In the example the first two cases in HiD1 have only one member in that household; while the third case has three members - but only first has value for TtW1 assigned


Example
HiD1 TtW1
6800683 E30000093
6800716 E30000093
6800782 E30000093
6800782
6800782
7154600 E30000093
7154624 E30000093
8795789 E30000175
8795789
8795789
8899000 E30000175
8975461 E30000175
8975461
8975461
...... .......

I have had a look at some of the syntax on SPSS tools but unable to find what I need

Any suggestions of a starting point gratefully received but do not have Python skills


Cheers
Muir


Muir Houston, HNC, BA (Hons), M.Phil., PhD, FHEA
College of Social Sciences Ethics Officer
Social Justice, Place and Lifelong Education Research
School of Education
University of Glasgow
0044+141-330-4699

Silver bullet or red herring? New evidence on the place of aspirations in education
R3L+ Project - Adult education in the light of the European Quality Strategy
http://www.learning-regions.net/

GINCO Project - Grundtvig International Network of Course Organisers
http://www.ginconet.eu/

THEMP - Tertiary Higher Education for People in Mid Life
http://themp.eu/ 
 

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: assigning string variable value to subsequent cases

Ruben Geert van den Berg
Reply | Threaded
Open this post in threaded view
|

Re: assigning string variable value to subsequent cases

Dale
In reply to this post by Muir Houston-3
I am a light duty SPSS user so this solution may not be of much help.  It sounds like you could cover this with a merge.  In SYSTAT it is a matter of simply exporting the IDs with the value to a "Key" file.  I then simply merge the Key into the data set using the ID as the key merge variable.  All ID's that are the same get the same other values.

You can also export the "key" to an excel sheet and use the if ID =XXXX then let [variable]=xxxxx in traditional syntax. You just write the code in excel and us the copy function to create all the statements so you do not retype. As you can use copy-paste to drop that into SPSS and run it.  It is less elegant for sure but is also an easy work around.

Dale

Dale Pietrzak, Ed.D., LPC-MH, CCMHC
Director, Office of Academic Evaluation & Assessment
University of South Dakota
414 East Clark Street
Vermillion, SD  57069
(605) 677-6497
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Muir Houston [[hidden email]]
Sent: Wednesday, July 09, 2014 6:20 AM
To: [hidden email]
Subject: assigning string variable value to subsequent cases

I have a dataset (160k cases) which has a string variable for household ID (HiD1) and this may have multiple cases (total members of household varies). Now I have second string variable identifying the travel to work area (TtW1) of groups of these households.

However only the first case in HiD1 has the value of TtW1 - if there are multiple members of the household their value for TtW1 is blank. What I want to do is assign the value of TtW1 to the multiple members of households indentified by multiple cases in HiD1

In the example the first two cases in HiD1 have only one member in that household; while the third case has three members - but only first has value for TtW1 assigned


Example
HiD1            TtW1
6800683 E30000093
6800716 E30000093
6800782 E30000093
6800782
6800782
7154600 E30000093
7154624 E30000093
8795789 E30000175
8795789
8795789
8899000 E30000175
8975461 E30000175
8975461
8975461
......          .......

I have had a look at some of the syntax on SPSS tools but unable to find what I need

Any suggestions of a starting point gratefully received but do not have Python skills


Cheers
Muir


Muir Houston, HNC, BA (Hons), M.Phil., PhD, FHEA
College of Social Sciences Ethics Officer
Social Justice, Place and Lifelong Education Research
School of Education
University of Glasgow
0044+141-330-4699

Silver bullet or red herring? New evidence on the place of aspirations in education
R3L+ Project - Adult education in the light of the European Quality Strategy
http://www.learning-regions.net/

GINCO Project - Grundtvig International Network of Course Organisers
http://www.ginconet.eu/

THEMP - Tertiary Higher Education for People in Mid Life
http://themp.eu/


=====================
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

=====================
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: assigning string variable value to subsequent cases

Muir Houston-3
In reply to this post by David Marso
Thanks I will now try and decipher TFM and also use Ruben's examples as a starting point

Cheers
Muir


Muir Houston, HNC, BA (Hons), M.Phil., PhD, FHEA
College of Social Sciences Ethics Officer
Social Justice, Place and Lifelong Education Research
School of Education
University of Glasgow
0044+141-330-4699

Silver bullet or red herring? New evidence on the place of aspirations in education
R3L+ Project - Adult education in the light of the European Quality Strategy
http://www.learning-regions.net/

GINCO Project - Grundtvig International Network of Course Organisers
http://www.ginconet.eu/

THEMP - Tertiary Higher Education for People in Mid Life
http://themp.eu/ 
 


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: 09 July 2014 12:24
To: [hidden email]
Subject: Re: assigning string variable value to subsequent cases

Look up IF and LAG in the fine manual!
--

Muir Houston-3 wrote

> I have a dataset (160k cases) which has a string variable for
> household ID
> (HiD1) and this may have multiple cases (total members of household
> varies). Now I have second string variable identifying the travel to
> work area (TtW1) of groups of these households.
>
> However only the first case in HiD1 has the value of TtW1 - if there
> are multiple members of the household their value for TtW1 is blank.
> What I want to do is assign the value of TtW1 to the multiple members
> of households indentified by multiple cases in HiD1
>
> In the example the first two cases in HiD1 have only one member in
> that household; while the third case has three members - but only
> first has value for TtW1 assigned
>
>
> Example
> HiD1 TtW1
> 6800683 E30000093
> 6800716 E30000093
> 6800782 E30000093
> 6800782
> 6800782
> 7154600 E30000093
> 7154624 E30000093
> 8795789 E30000175
> 8795789
> 8795789
> 8899000 E30000175
> 8975461 E30000175
> 8975461
> 8975461
> ...... .......
>
> I have had a look at some of the syntax on SPSS tools but unable to
> find what I need
>
> Any suggestions of a starting point gratefully received but do not
> have Python skills
>
>
> Cheers
> Muir
>
>
> Muir Houston, HNC, BA (Hons), M.Phil., PhD, FHEA College of Social
> Sciences Ethics Officer Social Justice, Place and Lifelong Education
> Research School of Education University of Glasgow
> 0044+141-330-4699
>
> Silver bullet or red herring? New evidence on the place of aspirations
> in education
> R3L+ Project - Adult education in the light of the European Quality
> Strategy
> http://www.learning-regions.net/
>
> GINCO Project - Grundtvig International Network of Course Organisers
> http://www.ginconet.eu/
>
> THEMP - Tertiary Higher Education for People in Mid Life
> http://themp.eu/
>  
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/assigning-string-variable-value-to-subsequent-cases-tp5726661p5726662.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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

=====================
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: assigning string variable value to subsequent cases

David Marso
Administrator
It is as simple as
IF (LAG(firstvar) EQ firstvar ) othervar=LAG(othervar).

Muir Houston-3 wrote
Thanks I will now try and decipher TFM and also use Ruben's examples as a starting point

Cheers
Muir


Muir Houston, HNC, BA (Hons), M.Phil., PhD, FHEA
College of Social Sciences Ethics Officer
Social Justice, Place and Lifelong Education Research
School of Education
University of Glasgow
0044+141-330-4699

Silver bullet or red herring? New evidence on the place of aspirations in education
R3L+ Project - Adult education in the light of the European Quality Strategy
http://www.learning-regions.net/

GINCO Project - Grundtvig International Network of Course Organisers
http://www.ginconet.eu/

THEMP - Tertiary Higher Education for People in Mid Life
http://themp.eu/ 
 


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: 09 July 2014 12:24
To: [hidden email]
Subject: Re: assigning string variable value to subsequent cases

Look up IF and LAG in the fine manual!
--

Muir Houston-3 wrote
> I have a dataset (160k cases) which has a string variable for
> household ID
> (HiD1) and this may have multiple cases (total members of household
> varies). Now I have second string variable identifying the travel to
> work area (TtW1) of groups of these households.
>
> However only the first case in HiD1 has the value of TtW1 - if there
> are multiple members of the household their value for TtW1 is blank.
> What I want to do is assign the value of TtW1 to the multiple members
> of households indentified by multiple cases in HiD1
>
> In the example the first two cases in HiD1 have only one member in
> that household; while the third case has three members - but only
> first has value for TtW1 assigned
>
>
> Example
> HiD1 TtW1
> 6800683 E30000093
> 6800716 E30000093
> 6800782 E30000093
> 6800782
> 6800782
> 7154600 E30000093
> 7154624 E30000093
> 8795789 E30000175
> 8795789
> 8795789
> 8899000 E30000175
> 8975461 E30000175
> 8975461
> 8975461
> ...... .......
>
> I have had a look at some of the syntax on SPSS tools but unable to
> find what I need
>
> Any suggestions of a starting point gratefully received but do not
> have Python skills
>
>
> Cheers
> Muir
>
>
> Muir Houston, HNC, BA (Hons), M.Phil., PhD, FHEA College of Social
> Sciences Ethics Officer Social Justice, Place and Lifelong Education
> Research School of Education University of Glasgow
> 0044+141-330-4699
>
> Silver bullet or red herring? New evidence on the place of aspirations
> in education
> R3L+ Project - Adult education in the light of the European Quality
> Strategy
> http://www.learning-regions.net/
>
> GINCO Project - Grundtvig International Network of Course Organisers
> http://www.ginconet.eu/
>
> THEMP - Tertiary Higher Education for People in Mid Life
> http://themp.eu/
>  
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/assigning-string-variable-value-to-subsequent-cases-tp5726661p5726662.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"