Combining two numerical variables with missing values

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

Combining two numerical variables with missing values

SophieR
Hi,

I have a dataset where respondents answered either question 1 or 2 - if they answered v1, then v2 will be blank.

v1   v2
1     .
2     .
3     .
.     4
.     5
.     6

I want to combine the two numerical variables into one variable. Seems simple but I'm stumped. Any help?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Combining two numerical variables with missing values

Maguin, Eugene
Well,
Compute v1v2=sum(v1,v2).

Gene Maguin

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of SophieR
Sent: Monday, January 05, 2015 12:02 PM
To: [hidden email]
Subject: Combining two numerical variables with missing values

Hi,

I have a dataset where respondents answered either question 1 or 2 - if they
answered v1, then v2 will be blank.

v1   v2
1     .
2     .
3     .
.     4
.     5
.     6

I want to combine the two numerical variables into one variable. Seems
simple but I'm stumped. Any help?

Thanks



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Combining-two-numerical-variables-with-missing-values-tp5728337.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: Combining two numerical variables with missing values

SophieR
*head hits desk*

I think I left my brain in 2014

Thanks Gene
Reply | Threaded
Open this post in threaded view
|

Re: Combining two numerical variables with missing values

PRogman
In reply to this post by SophieR
In the Command Syntax Reference look up command IF, there is also a section on missing values and IF...
See also  transformation function MISSING(...)
Then try syntax
IF MISSING(v1) v3 = v2.
IF MISSING(v2) v3 = v1.
EXECUTE.
Alternative:
COMPUTE v3 = v1*MISSING(v2) + v2*MISSING(v1).
EXECUTE.

HTH,
PR



Reply | Threaded
Open this post in threaded view
|

Re: Combining two numerical variables with missing values

Art Kendall
In reply to this post by SophieR
compute v3 = sum.1(1,2).
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Combining two numerical variables with missing values

Jignesh Sutar
In reply to this post by SophieR
Just a quick tip (if you haven't already), that it's always wise to double check that the two variables are indeed mutually exclusive. It may occur that even though the two variable are meant to be mutually exclusive they might actually not be.

So something like this is always a good preliminary check:

temp.
recode v1 v2 (sysmis=-999) (else=copy).
cro v1 by v2.

Once your satisfied they are mutually exclusive then it's best to go ahead with SUM compute.


On 5 January 2015 at 17:18, SophieR <[hidden email]> wrote:
*head hits desk*

I think I left my brain in 2014

Thanks Gene



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Combining-two-numerical-variables-with-missing-values-tp5728337p5728339.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: Combining two numerical variables with missing values

Art Kendall
it certainly is      good to check that the two variables are mutually exclusive.

Good suggestion to use a user-missing value on the reeode!  When the user assigns a missing value, or a value is missing for a reason known to the user, user-missing values should be  used.

sysmis is valuable way to tell when the system cannot do what the user is telling it to do.

However, in this instance, a crosstab would show whether or not the variables were mutually exclusive.

crosstab tables= v1 by v2 /missing=include.
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Combining two numerical variables with missing values

Rich Ulrich
In reply to this post by Maguin, Eugene
Or, to get around the problem of both being present:

COMPUTE v1v2= max.1(v1,v2).

--
Rich Ulrich

> Date: Mon, 5 Jan 2015 17:09:15 +0000

> From: [hidden email]
> Subject: Re: Combining two numerical variables with missing values
> To: [hidden email]
>
> Well,
> Compute v1v2=sum(v1,v2).
>
> Gene Maguin
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of SophieR
> Sent: Monday, January 05, 2015 12:02 PM
> To: [hidden email]
> Subject: Combining two numerical variables with missing values
>
> Hi,
>
> I have a dataset where respondents answered either question 1 or 2 - if they
> answered v1, then v2 will be blank.
>
> v1 v2
> 1 .
> 2 .
> 3 .
> . 4
> . 5
> . 6
>
> I want to combine the two numerical variables into one variable. Seems
> simple but I'm stumped. Any help?
>

===================== 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: Combining two numerical variables with missing values

John F Hall
In reply to this post by Jignesh Sutar

You can also check with:

 

COUNT x = v1 v2 (1 thru hi).

FREQ x.

 

X should be either 1 or 0.  If it’s 2 you have errors as per Jignesh.

 

Check out DO IF …ELSE IF, but why complicate things?  Be careful with COMPUTE as it may set all new values to missing.  Provided there are no errors, Art’s solution gets round this and is the simplest.  Head bangers can always look at the tutorials on my site.

 

John F Hall (Mr)

[Retired academic survey researcher]

 

Email:   [hidden email] 

Website: www.surveyresearch.weebly.com

SPSS start page:  www.surveyresearch.weebly.com/1-survey-analysis-workshop

 

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jignesh Sutar
Sent: 05 January 2015 18:32
To: [hidden email]
Subject: Re: Combining two numerical variables with missing values

 

Just a quick tip (if you haven't already), that it's always wise to double check that the two variables are indeed mutually exclusive. It may occur that even though the two variable are meant to be mutually exclusive they might actually not be.

 

So something like this is always a good preliminary check:

 

temp.

recode v1 v2 (sysmis=-999) (else=copy).

cro v1 by v2.

 

Once your satisfied they are mutually exclusive then it's best to go ahead with SUM compute.

 

 

On 5 January 2015 at 17:18, SophieR <[hidden email]> wrote:

*head hits desk*

I think I left my brain in 2014

Thanks Gene



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Combining-two-numerical-variables-with-missing-values-tp5728337p5728339.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

===================== 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: Combining two numerical variables with missing values

David Marso
Administrator
In reply to this post by Maguin, Eugene
Keeping in mind the possibility of the 2 vars not being mutually exclusive.
Consider:

IF MIN(v1,v2) EQ MAX(v1,v2) v3=MAX(v1,v2).

In cases where both are answered the result will be SYSMIS (or the min=max).

Maguin, Eugene wrote
Well,
Compute v1v2=sum(v1,v2).

Gene Maguin

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of SophieR
Sent: Monday, January 05, 2015 12:02 PM
To: [hidden email]
Subject: Combining two numerical variables with missing values

Hi,

I have a dataset where respondents answered either question 1 or 2 - if they
answered v1, then v2 will be blank.

v1   v2
1     .
2     .
3     .
.     4
.     5
.     6

I want to combine the two numerical variables into one variable. Seems
simple but I'm stumped. Any help?

Thanks



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Combining-two-numerical-variables-with-missing-values-tp5728337.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?"
Reply | Threaded
Open this post in threaded view
|

Re: Combining two numerical variables with missing values

Manoj Arora (DEL/Abacus Analytics)
In reply to this post by SophieR
Hi,

Please take the mean or sum of both the variables.

Compute n_v1v2=sum(v1,v2).
Execute.

Or

Compute n_v1v2=mean(v1,v2).
Execute.

Regards





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
SophieR
Sent: Monday, January 05, 2015 10:31 PM
To: [hidden email]
Subject: Combining two numerical variables with missing values

Hi,

I have a dataset where respondents answered either question 1 or 2 - if they
answered v1, then v2 will be blank.

v1   v2
1     .
2     .
3     .
.     4
.     5
.     6

I want to combine the two numerical variables into one variable. Seems
simple but I'm stumped. Any help?

Thanks




--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Combining-two-numerical-variab
les-with-missing-values-tp5728336.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


http://www.imrbint.com/disclaimer.html

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