Sum

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

Sum

MOUNKARA Yakoubou
Hello!
I need a help if passible!
I have 
COMPUTE Revtot = Q15A3 + Q15B3 + Q15C3 .
EXECUTE .
Among the three variables there are some missing. When running the script revtot becomes missing. How can i write this code so that i can cope with each situation?

--
MOUNKARA Yakoubou

Cell:+227 96 96 78 24
      +227 21 79 17 11
bur Tel: +227 20 72 32 75
Reply | Threaded
Open this post in threaded view
|

Re: Sum

Daciuk, Tim

Compute revtot = sum.1(Q15A3,Q15B3,Q15C3).

 

As long as there is one valid value, a sum will be computed.

 

Tim Daciuk

Director, Worldwide Demo Resources

SPSS Inc.

 

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of MOUNKARA Yakoubou
Sent: Monday, February 16, 2009 5:55 AM
To: [hidden email]
Subject: Sum

 

Hello!

I need a help if passible!

I have 

COMPUTE Revtot = Q15A3 + Q15B3 + Q15C3 .

EXECUTE .

Among the three variables there are some missing. When running the script revtot becomes missing. How can i write this code so that i can cope with each situation?


--
MOUNKARA Yakoubou

Cell:+227 96 96 78 24
      +227 21 79 17 11
bur Tel: +227 20 72 32 75

Reply | Threaded
Open this post in threaded view
|

Re: Sum

Albert-Jan Roskam
In reply to this post by MOUNKARA Yakoubou
Hi Mounkara,
 
The missing values represent any value so the outcome is always missing. If you recode it to zero, you can sum it.
 
*sample data.

data list / x1 1-1 x2 3-3 x3 5-5.
begin data
1 4 8
1
1 6
1   8
end data.

 

*actual code.

recode x1 to x3 (sysmis = 0) (else = copy) into #y1 to #y3.

compute revtot = #y1 + #y2 + #y3.
* or alternatively:.

compute mysum = sum (x1 to x3).
exe.



From: MOUNKARA Yakoubou <[hidden email]>
To: [hidden email]
Sent: Monday, February 16, 2009 11:54:31 AM
Subject: Sum

Hello!
I need a help if passible!
I have 
COMPUTE Revtot = Q15A3 + Q15B3 + Q15C3 .
EXECUTE .
Among the three variables there are some missing. When running the script revtot becomes missing. How can i write this code so that i can cope with each situation?

--
MOUNKARA Yakoubou

Cell:+227 96 96 78 24
      +227 21 79 17 11
bur Tel: +227 20 72 32 75