Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Compute Variable = .

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-23-2014 01:31 AM

I have

A=.

B = 10

C=5

I want to obtain

D= A + (B*C)

but I get D=.

it should be D=50

how do I overcome this issue?

Thanks

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to apple

01-23-2014 01:35 AM

Please use sum and mult functions as '+' operator will give missing values...hope it helped.

Thank You

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to apple

01-23-2014 05:09 AM

D=sum(A, B*C);

or use if-else logic to customize the missing cases. e.g.

if missing(A)=1 then A1=0; /* not necessarily so */

else A1=A;

if missing(B)=1 then B1=0; /* not necessarily so */

else B1=B;

if missing(C)=1 then C1=1; /* not necessarily so */

else C1=C;

D=A1+B1*C1;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to apple

01-23-2014 05:50 AM

How About,,

**data** _null_;

a=**.**;

b=**5**;

c=**10**;

d=Sum(a,B*c);

Put d;

**run**;

,

Thanks,

Sanjeev.K

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kuridisanjeev

01-23-2014 07:08 AM

This will work for missing values of A, you cannont have missing values while you are multiplying.. hope answered the question.

Thank You

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to apple

01-24-2014 12:34 PM

Apple,

There have been many good examples on how to calculate the answer that you want. I'd like to address this in a different way (that might make sense if you consider only + and * as operators). With a missing value for A in your example, you say the answer should be 50. My question is "How do you know"? A is missing and not necessarily equal to zero. It might be anything--you just don't have information. Consequently, any function that includes A as an operand is lacking in information. SAS thus rightly treats the result as missing. If you know that A is truly equal to zero when missing, then I would write something like bill0101's if-then-else logic.

Steve Denham