BookmarkSubscribeRSS Feed
tyw2304
Calcite | Level 5

Hi everyone,

 

I'm using SAS for the very first time and it would be much appreciated if any of you could help me a favour.

 

Basically I have the data A as shown below here :

 

1.PNG

 

So I would like to get the final result (TOTAL column) as shown below, where TOTAL = cumulative + OS - 10 , e.g -7 = 2+1-10 and -2 = 6+2-10 . So I would like to know is there a way to compute the final result like below using SAS?

 

2.PNG 

5 REPLIES 5
Kurt_Bremser
Super User

Please post example data in usable form, like

data have;
input yr mth pd cumulative os;
datalines;
2004 12 24 24 10
;

For your solution, you only need to insert the formula you stated:

data want;
set have;
total = cumulative + os - 10;
keep yr mth total;
run;

Why does the first observation in your expected output have a minus sign as total? According to your formula, that should be 24.

tyw2304
Calcite | Level 5

Yes it's a negative value and I want it to be -10 at the back of the equation

Kurt_Bremser
Super User

In your first observation, cumulative is 24 and OS is 10. 24 + 10 - 10 gives 24, and not just a minus sign (which is impossible with SAS numbers, anyway).

Please clarify.

tyw2304
Calcite | Level 5

The cumulative 24 is a baseline for Dec 2014, therefore we don't consider 24 as we don't have any data from Dec 2013 for comparison, so only consider the following months of 2015, where the TOTAL column is calculated with respective to Dec 2014.

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
  • 5 replies
  • 475 views
  • 0 likes
  • 2 in conversation