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 :
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?
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.
Yes it's a negative value and I want it to be -10 at the back of the equation
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.
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.
So when do you start your calculation? Is it the first January (for a given group, if such can be determined)?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.