fyear | gvkey | month | trt1m |
2010 | 1004 | 1 | 0.826806 |
2010 | 1004 | 2 | -2.1148 |
2010 | 1004 | 3 | 9.43563 |
2010 | 1004 | 4 | -1.77276 |
2010 | 1004 | 5 | -19.1961 |
2010 | 1004 | 6 | -15.0254 |
2010 | 1004 | 7 | 0.358423 |
2010 | 1004 | 8 | -8.57143 |
2010 | 1004 | 9 | 21.4844 |
2010 | 1004 | 10 | 18.1136 |
2010 | 1004 | 11 | 11.4338 |
2010 | 1004 | 12 | 11.8485 |
2011 | 1004 | 1 | -2.47543 |
2011 | 1004 | 2 | 1.86637 |
2011 | 1004 | 3 | 1.57567 |
2011 | 1004 | 4 | -5.79004 |
2011 | 1004 | 5 | 1.34409 |
2011 | 1004 | 6 | 2.65252 |
2011 | 1004 | 7 | 8.5825 |
2011 | 1004 | 8 | -19.5978 |
2011 | 1004 | 9 | -29.3345 |
2011 | 1004 | 10 | 20.006 |
2011 | 1004 | 11 | -8.37933 |
2011 | 1004 | 12 | 4.98357 |
2012 | 1004 | 1 | 10.9285 |
2012 | 1004 | 2 | 4.05852 |
2012 | 1004 | 3 | -17.2336 |
2012 | 1004 | 4 | -14.9315 |
2012 | 1004 | 5 | -22.0065 |
2012 | 1004 | 6 | 11.8672 |
2012 | 1004 | 7 | 5.97181 |
2012 | 1004 | 8 | 4.71499 |
2012 | 1004 | 9 | 10.3495 |
2012 | 1004 | 10 | -7.64312 |
2012 | 1004 | 11 | 1.78926 |
2012 | 1004 | 12 | 21.6146 |
2013 | 1004 | 1 | 1.31156 |
2013 | 1004 | 2 | -6.79045 |
2013 | 1004 | 3 | 4.66705 |
2013 | 1004 | 4 | -2.47417 |
2013 | 1004 | 5 | 12.318 |
2013 | 1004 | 6 | 9.57129 |
2013 | 1004 | 7 | 10.6233 |
2013 | 1004 | 8 | 3.5066 |
2013 | 1004 | 9 | 8.92786 |
2013 | 1004 | 10 | 7.40944 |
2013 | 1004 | 11 | 6.62568 |
2013 | 1004 | 12 | -10.2819 |
2014 | 1004 | 1 | -4.58765 |
2014 | 1004 | 2 | 8.44278 |
2014 | 1004 | 3 | -10.2076 |
2014 | 1004 | 4 | 0.096339 |
2014 | 1004 | 5 | -6.17761 |
2014 | 1004 | 6 | 13.4156 |
2014 | 1004 | 7 | -2.12264 |
2014 | 1004 | 8 | 2.97398 |
2014 | 1004 | 9 | -12.8159 |
2014 | 1004 | 10 | 10.0414 |
2014 | 1004 | 11 | -3.28302 |
2014 | 1004 | 12 | 8.38861 |
2015 | 1004 | 1 | 3.43772 |
2015 | 1004 | 2 | 2.582 |
2015 | 1004 | 3 | 4.42177 |
2015 | 1004 | 4 | -1.25407 |
2015 | 1004 | 5 | -2.31481 |
2015 | 1004 | 6 | 7.88761 |
2015 | 1004 | 7 | -15.2024 |
2015 | 1004 | 8 | -9.72171 |
2015 | 1004 | 9 | -22.0304 |
2015 | 1004 | 10 | 20.0053 |
2015 | 1004 | 11 | 8.24152 |
2015 | 1004 | 12 | 7.04397 |
2016 | 1004 | 1 | -19.7984 |
2016 | 1004 | 2 | 1.3327 |
2016 | 1004 | 3 | 9.30014 |
2016 | 1004 | 4 | 3.63128 |
2016 | 1004 | 5 | 1.5391 |
2016 | 1004 | 6 | -4.38345 |
2016 | 1004 | 7 | 3.83462 |
2016 | 1004 | 8 | 1.86258 |
2016 | 1004 | 9 | 27.2653 |
2016 | 1004 | 10 | 2.95338 |
2016 | 1004 | 11 | 14.6721 |
2016 | 1004 | 12 | -10.4093 |
2010 | 1013 | 1 | -14.4928 |
2010 | 1013 | 2 | 19.3974 |
2010 | 1013 | 3 | 15.2997 |
2010 | 1013 | 4 | 9.43912 |
2010 | 1013 | 5 | 3.25 |
2010 | 1013 | 6 | -10.2906 |
2010 | 1013 | 7 | 71.7949 |
2010 | 1013 | 8 | -0.39277 |
2010 | 1013 | 9 | -0.07886 |
2010 | 1013 | 10 | 0.157853 |
2010 | 1013 | 11 | 0.236407 |
2010 | 1013 | 12 | 0.235849 |
2010 | 1045 | 1 | -10.4787 |
2010 | 1045 | 2 | 32.8035 |
2010 | 1045 | 3 | -0.87051 |
2010 | 1045 | 4 | -18.9901 |
2010 | 1045 | 5 | 3.92954 |
2010 | 1045 | 6 | -11.6037 |
2010 | 1045 | 7 | 4.42478 |
2010 | 1045 | 8 | -13.5593 |
2010 | 1045 | 9 | 2.45098 |
2010 | 1045 | 10 | 25.8373 |
2010 | 1045 | 11 | 8.49176 |
2010 | 1045 | 12 | -8.99533 |
I want to calculate cumulative quarterly return from this monthly return data. Please let me know which sas code I should use. For example, I want calculate 4 quarter return for a year.
q1ret= (1+trt1m1)*(1+trt1m2)*(1+trt1m3)
Thank you.
Please provide sample data via a SAS data step so we don't have to do this work for you.
Members in this forum really like to help but you're expected to also demonstrate some own work. This doesn't need to be fully working code. Just show us what you've tried so far (may be some not yet working code) so we can better understand where you are at and take you from there.
I believe this is now already your 4th consecutive post where you've just posted data, stated the problem and then expect people to serve you. Please change this approach.
To give you a hint for your current question:
1. Use the mdy() function using your year and month variable and create a SAS date value
2. Use this SAS date value for grouping (i.e. by applying format YYQ.)
Once you've made the changes suggested via @Patrick you can look into PROC EXPAND and/or TIMESERIES to do the conversion.
Do you want rolling quarterly returns, or calendar quarters?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.