LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2010, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 12 Mar 2010 22:41:22 -0500
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: Sum across variables when there are missing values
Comments: To: Neil Fernando <neilfrnnd@YAHOO.COM>

Neil,

I'm glad to hear that Muthia's solution did what you needed, but I don't see any reason why you would include score in the calculation. i.e., I think the following does what you want and should run slightly quicker:

DATA food2; SET food1; score = sum(item1, item2, item3); RUN;

HTH, Art --------- On Fri, 12 Mar 2010 18:49:39 -0800, Neil Fernando <neilfrnnd@YAHOO.COM> wrote:

>Hi Muthia,

This is great!?It worked correctly. Now I can apply for my bigger data set.

Thanks again!

Neil ? Neil Fernando

E-mail : neilfrnnd@yahoo.com

________________________________ From: Muthia Kachirayan <muthia.kachirayan@GMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Sent: Fri, March 12, 2010 10:00:51 PM Subject: Re: Sum across variables when there are missing values

Use SUM() function instead.

score = sum(score, item1, item2, item3);

On Fri, Mar 12, 2010 at 9:42 PM, Neil Fernando <neilfrnnd@yahoo.com> 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; > cards; > 0 . 1 > . . 1 > 0 0 . > 1 . 1 > ; > run; > > > DATA food2; >? SET food1; >? ? score = item1 + item2 + item3; > > RUN; > > > 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 : neilfrnnd@yahoo.com >


Back to: Top of message | Previous page | Main SAS-L page