Hi all
i have a one dataset with two variables cost,vat as follows
data x;
input cost vat;
datalines;
1000 100
5000 500
10000 .
. .
;
Now i want to add these two variables and addition of these two variables in new variable ADDITION and i dont want missing values in these variable.
Thanks &Regards
rawindarreddy
use sum function.
Hi,
Try this..Hope it helps
data x;
input cost vat;
x=sum(cost,vat);
if x ne .;
datalines;
1000 100
5000 500
10000 .
. .
;
run;
Thanks,
Shiva
If all arguments to SUM function are missing it will still return missing.
The only option as I can see it, depending on why the missing are objectionable in the data, are to remove the record from the output or assign a specific value such as 0 if both variables are missing.
you can add a 0 as one of the parameters in SUM to prevent returning a missing value -- SUM(0,cost,vat)
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.