Date: Fri, 12 Mar 2010 22:00:51 -0400
Reply-To: Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Subject: Re: Sum across variables when there are missing values
Content-Type: text/plain; charset=ISO-8859-1
Use SUM() function instead.
score = sum(score, item1, item2, item3);
On Fri, Mar 12, 2010 at 9:42 PM, Neil Fernando <firstname.lastname@example.org> wrote:
> Dear Colleagues,
> I have a query as to how the sum of item 1, item2 and item3 could be
> obtained across rows when there are missing values
> (in SAS).
> data food1;
> input item1 item2 item3;
> 0 . 1
> . . 1
> 0 0 .
> 1 . 1
> DATA food2;
> SET food1;
> score = item1 + item2 + item3;
> My query: I created a new variable named 'score' in food2 dataset. But it
> does not give the sum of item1, item2 and item3, instead it gives a period
> (.) because of missing values.
> I would appreciate if you could let me know how to get the sum across rows.
> Thank you for your time.
> Neil Fernando
> E-mail : email@example.com