BookmarkSubscribeRSS Feed
rawindar
Calcite | Level 5

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

4 REPLIES 4
manojinpec
Obsidian | Level 7

use sum function.

shivas
Pyrite | Level 9

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

ballardw
Super User

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.

Jay_TxOAG
Quartz | Level 8

you can add a 0 as one of the parameters in SUM to prevent returning a missing value -- SUM(0,cost,vat)

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 961 views
  • 0 likes
  • 5 in conversation