DATA Step, Macro, Functions and more

re: Column Product

Regular Contributor
Posts: 248

re: Column Product

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



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





Cum_Variance 2.012776
Super User
Posts: 13,942

Re: re: Column Product

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;

data want;
   set have;
   by company;
   retain firstclaim ;
   if then firstclaim=claim;
   if then do;
      cum_variance = claim/firstclaim;


You should know by now how to post data as a datastep and to use the code boxes for posting code.

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation