Hi, I would like to multiply the entries in a column similar to the product function in excel. That is, I have the number of claims for there respective fiscal year and would like to mutliply the changes between the fiscal years as in the column Change below. Each year I add new information to the dataset so that the number of fiscal years will change. Any suggestion on how I can do this....thanks
Have:
FiscalYear | Claims | Change |
2007-2008 | 1168719 | |
2008-2009 | 1249323 | 1.068968 |
2009-2010 | 1295424 | 1.036901 |
2010-2011 | 1346699 | 1.039582 |
2011-2012 | 1392185 | 1.033776 |
2012-2013 | 1504159 | 1.08043 |
2013-2014 | 1642564 | 1.092015 |
2014-2015 | 1955435 | 1.190477 |
2015-2016 | 2215927 | 1.133214 |
2016-2017 | 2352370 | 1.061574 |
Want:
Cum_Variance | 2.012776 |
I don't see any "product" involved. That looks like last claim/ first claim.
Is there supposed to be grouping variable involved such as a company name?
If so
proc sort data=have; by company fiscalyear; run; data want; set have; by company; retain firstclaim ; if first.company then firstclaim=claim; if last.company then do; cum_variance = claim/firstclaim; output; end; run;
You should know by now how to post data as a datastep and to use the code boxes for posting code.
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.