BookmarkSubscribeRSS Feed
twildone
Pyrite | Level 9

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
1 REPLY 1
ballardw
Super User

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.

sas-innovate-2024.png

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.

 

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
  • 1 reply
  • 689 views
  • 0 likes
  • 2 in conversation