BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Agent1592
Pyrite | Level 9

Dear SAS Community:

I am looking to compute the cumulative return. I have monthly stock returns panel data. I would like to compute the cumulative return for each stock.

Unfortunately the current code produces results just for the first Date. How can I improve the code so that I have cumulative returns for all the months.

data test;
set test; 
by ticker Date; 
if first.ticker then do cumuret=0; end; 
cumuret=(1+cumuret)*(1+return/100)-1; 
run;

 This is the want table:

DatetickerreturnCum_ret
1/29/201013011.0810850
2/26/201013013.7234070.037234
3/31/201013014.615390.085106
4/30/20101301-5.0251250.030579
5/28/20101301-5.789476-0.02909
data WORK.TEST;
  infile datalines dsd truncover;
  input Date:MMDDYY8. ticker:$8. return:32.;
  format Date MMDDYY8.;
  label ticker="ticker";
datalines4;
01/29/10,1301,1.081085
02/26/10,1301,3.723407
03/31/10,1301,4.61539
04/30/10,1301,-5.025125
05/28/10,1301,-5.789476
06/30/10,1301,1.117313
07/30/10,1301,-0.5524874
08/31/10,1301,-2.222222
09/30/10,1301,-1.675975
10/29/10,1301,-11.731845
11/30/10,1301,9.493673
12/31/10,1301,4.046237
01/31/11,1301,1.111114
02/28/11,1301,4.347825
03/31/11,1301,-5.729163
04/29/11,1301,-11.111111
05/31/11,1301,4.999995
06/30/11,1301,10.179639
07/29/11,1301,0
08/31/11,1301,-1.0929
09/30/11,1301,2.222228
10/31/11,1301,-3.80435
11/30/11,1301,-1.685393
12/30/11,1301,1.714289
01/31/12,1301,3.932583
02/29/12,1301,8.196724
03/30/12,1301,2.525258
04/30/12,1301,-4.545456
05/31/12,1301,-5.291003
06/29/12,1301,4.972374
07/31/12,1301,-1.05263
08/31/12,1301,-5.319148
09/28/12,1301,-5.464482
10/31/12,1301,2.312136
11/30/12,1301,3.409088
12/31/12,1301,6.593406
01/31/13,1301,5.154634
02/28/13,1301,7.425737
03/28/13,1301,1.843321
04/30/13,1301,14.351856
05/31/13,1301,11.336029
06/28/13,1301,12.3348
07/31/13,1301,1.96079
08/30/13,1301,-1.132077
09/30/13,1301,8.396948
10/31/13,1301,-5.985916
11/29/13,1301,-2.583027
12/31/13,1301,0.757575
01/31/14,1301,0.3759384
02/28/14,1301,0.3759384
03/31/14,1301,0
04/30/14,1301,0
05/30/14,1301,-1.893938
06/30/14,1301,0.386095
07/31/14,1301,-0.7692337
08/29/14,1301,-2.692306
09/30/14,1301,2.7668
10/31/14,1301,0
11/28/14,1301,6.225681
12/31/14,1301,0.7326007
01/30/15,1301,0.727272
02/27/15,1301,7.553959
03/31/15,1301,-3.344482
04/30/15,1301,-3.832752
05/29/15,1301,4.693139
06/30/15,1301,-2.413791
07/31/15,1301,-1.060069
08/31/15,1301,-4.285717
09/30/15,1301,-1.872659
10/30/15,1301,0
11/30/15,1301,1.9084
12/31/15,1301,3.745317
01/29/16,1301,-0.3649652
02/29/16,1301,-4.029304
03/31/16,1301,0.3816724
04/29/16,1301,-1.145041
05/31/16,1301,3.474903
06/30/16,1301,-2.621722
07/29/16,1301,1.532567
08/31/16,1301,-1.132077
09/30/16,1301,5.134094
10/31/16,1301,0.6924152
11/30/16,1301,-2.242315
12/30/16,1301,0.9988904
01/31/17,1301,-0.2930403
02/28/17,1301,8.947563
03/31/17,1301,0.8414626
04/28/17,1301,-3.852326
05/31/17,1301,4.088581
06/30/17,1301,2.148759
07/31/17,1301,0.4854321
08/31/17,1301,8.212555
09/29/17,1301,-1.183432
10/31/17,1301,9.730541
11/30/17,1301,4.76191
12/29/17,1301,13.324535
01/31/18,1301,-3.608847
02/28/18,1301,-10.606062
03/29/18,1301,1.1734
04/30/18,1301,-1.178008
05/31/18,1301,0.1324534
06/29/18,1301,-4.76821
07/31/18,1301,-3.198886
08/31/18,1301,-9.626436
09/28/18,1301,5.426359
10/31/18,1301,-8.970589
01/29/10,1332,0.3831387
02/26/10,1332,-1.8797
03/31/10,1332,5.747128
04/30/10,1332,1.865673
05/28/10,1332,-0.3717482
06/30/10,1332,7.089555
07/30/10,1332,2.439022
08/31/10,1332,-9.863943
09/30/10,1332,2.941167
10/29/10,1332,-8.8968
11/30/10,1332,-3.515625
12/31/10,1332,3.643727
01/31/11,1332,3.125
02/28/11,1332,4.119849
03/31/11,1332,-15.107918
04/29/11,1332,-1.310045
05/31/11,1332,6.637168
06/30/11,1332,11.864412
07/29/11,1332,5.283022
08/31/11,1332,1.075268
09/30/11,1332,5.653715
10/31/11,1332,-9.183675
11/30/11,1332,-2.272725
12/30/11,1332,2.325583
01/31/12,1332,3.0303
02/29/12,1332,2.930403
03/30/12,1332,2.135229
04/30/12,1332,-7.446808
05/31/12,1332,-16.09196
06/29/12,1332,-2.262443
07/31/12,1332,-16.2037
08/31/12,1332,-4.972374
09/28/12,1332,-5.084747
10/31/12,1332,4.166663
11/30/12,1332,-18.43575
12/31/12,1332,21.91781
01/31/13,1332,2.24719
02/28/13,1332,5.494511
03/28/13,1332,-5.208331
04/30/13,1332,3.846157
05/31/13,1332,4.2328
06/28/13,1332,-5.7971
07/31/13,1332,2.051282
08/30/13,1332,-1.951218
09/30/13,1332,4.975128
10/31/13,1332,-5.213273
11/29/13,1332,10.837436
12/31/13,1332,6.222224
01/31/14,1332,-11.715484
02/28/14,1332,4.14747
03/31/14,1332,-3.9823
04/30/14,1332,10.328638
05/30/14,1332,36.59575
06/30/14,1332,-2.492213
07/31/14,1332,-4.472846
08/29/14,1332,-4.430377
09/30/14,1332,-4.304636
10/31/14,1332,13.148785
11/28/14,1332,30.59937
12/31/14,1332,-8.9372
01/30/15,1332,8.488059
02/27/15,1332,1.265824
03/31/15,1332,-8
04/30/15,1332,-1.621622
05/29/15,1332,-1.604277
06/30/15,1332,-4.891306
07/31/15,1332,11.714292
08/31/15,1332,-2.8133
09/30/15,1332,-6.036747
10/30/15,1332,14.325846
11/30/15,1332,3.9312
12/31/15,1332,60.52009
01/29/16,1332,-8.357769
02/29/16,1332,-16.32
03/31/16,1332,5.162525
04/29/16,1332,6.2937
05/31/16,1332,3.947365
06/30/16,1332,-16.8254
07/29/16,1332,-3.947371
08/31/16,1332,-15.068495
09/30/16,1332,1.99064
10/31/16,1332,16.62817
11/30/16,1332,1.984131
12/30/16,1332,9.338522
01/31/17,1332,-1.067615
02/28/17,1332,0.8880973
03/31/17,1332,-1.672536
04/28/17,1332,-6.325823
05/31/17,1332,7.635009
06/30/17,1332,13.471508
07/31/17,1332,-1.978689
08/31/17,1332,-3.881985
09/29/17,1332,4.111838
10/31/17,1332,9.697938
11/30/17,1332,-10.625911
12/29/17,1332,-1.669449
01/31/18,1332,-1.528013
02/28/18,1332,-7.058823
03/29/18,1332,0
04/30/18,1332,8.196724
05/31/18,1332,-10.269361
06/29/18,1332,1.865673
07/31/18,1332,0.5494475
08/31/18,1332,11.111116
09/28/18,1332,22.97521
10/31/18,1332,-2.567565
05/30/14,1333,-0.8641958
06/30/14,1333,3.051054
07/31/14,1333,-1.38973
08/29/14,1333,-0.9174287
09/30/14,1333,0.8641958
10/31/14,1333,-1.897186
11/28/14,1333,7.956016
12/31/14,1333,8.328342
01/30/15,1333,-2.710176
02/27/15,1333,2.540421
03/31/15,1333,-2.927929
04/30/15,1333,-2.408934
05/29/15,1333,11.785709
06/30/15,1333,5.378067
07/31/15,1333,2.930772
08/31/15,1333,-10.554737
09/30/15,1333,-6.379497
10/30/15,1333,5.998838
11/30/15,1333,7.637358
12/31/15,1333,9.086264
01/29/16,1333,6.998587
02/29/16,1333,-1.229149
03/31/16,1333,-5.377781
04/29/16,1333,12.062609
05/31/16,1333,6.08052
06/30/16,1333,9.771479
07/29/16,1333,-7.160669
08/31/16,1333,-7.828087
09/30/16,1333,13.145924
10/31/16,1333,6.4304
11/30/16,1333,0.2756715
12/30/16,1333,8.419239
01/31/17,1333,-1.10935
02/28/17,1333,6.487346
03/31/17,1333,1.485872
04/28/17,1333,-7.44986
05/31/17,1333,-0.47096
06/30/17,1333,-6.813187
07/31/17,1333,1.4151
08/31/17,1333,5.980062
09/29/17,1333,7.993472
10/31/17,1333,5.589128
11/30/17,1333,-5.417275
12/29/17,1333,7.594931
01/31/18,1333,-5.441177
02/28/18,1333,-3.805172
03/29/18,1333,7.436705
04/30/18,1333,9.836065
05/31/18,1333,12.754404
06/29/18,1333,8.262455
07/31/18,1333,-6.734008
08/31/18,1333,-7.220215
09/28/18,1333,11.584557
10/31/18,1333,-2.386636
01/29/10,1334,-1.5625
02/26/10,1334,0.8000016
03/31/10,1334,7.936513
04/30/10,1334,0
05/28/10,1334,2.255642
06/30/10,1334,0
07/30/10,1334,1.47059
08/31/10,1334,-1.449275
09/30/10,1334,0.7246375
10/29/10,1334,-7.042253
11/30/10,1334,0.757575
12/31/10,1334,1.503754
01/31/11,1334,5.92593
02/28/11,1334,5.517244
03/31/11,1334,-18.30065
04/29/11,1334,-1.639342
05/31/11,1334,0
06/30/11,1334,11.2069
07/29/11,1334,3.846157
08/31/11,1334,0
09/30/11,1334,14.1791
10/31/11,1334,-6.535947
11/30/11,1334,-4.929578
12/30/11,1334,5.185187
01/31/12,1334,2.816904
02/29/12,1334,-0.6944418
03/30/12,1334,3.496504
04/30/12,1334,-4.137933
05/31/12,1334,-15.107912
06/29/12,1334,2.439022
07/31/12,1334,-7.142859
08/31/12,1334,16.23932
09/28/12,1334,-8.69565
10/31/12,1334,3.968251
11/30/12,1334,3.787875
12/31/12,1334,10.218978
01/31/13,1334,5.298018
02/28/13,1334,11.111116
03/28/13,1334,7.647061
04/30/13,1334,8.333338
05/31/13,1334,-5.641026
06/28/13,1334,4.188478
07/31/13,1334,0
08/30/13,1334,-8
09/30/13,1334,1.086962
10/31/13,1334,1.075268
11/29/13,1334,0.5376339
12/31/13,1334,-2.139038
01/31/14,1334,-7.103825
02/28/14,1334,1.744187
01/29/10,1352,3.921568
02/26/10,1352,0
03/31/10,1352,20.75472
04/30/10,1352,5.6
05/28/10,1352,-10.606062
06/30/10,1352,-11.016947
07/30/10,1352,13.333332
08/31/10,1352,-10.084033
09/30/10,1352,-3.571427
10/29/10,1352,-17.27273
11/30/10,1352,13.186812
12/31/10,1352,0.9708762
01/31/11,1352,3.846157
02/28/11,1352,0.9174347
03/31/11,1352,-2.727276
04/29/11,1352,-5.319148
05/31/11,1352,-3.370786
06/30/11,1352,6.896555
07/29/11,1352,0
08/31/11,1352,1.086962
09/30/11,1352,-4.347825
10/31/11,1352,-3.409094
11/30/11,1352,0
12/30/11,1352,14.772725
01/31/12,1352,21.78218
02/29/12,1352,1.626015
03/30/12,1352,-3.2
04/30/12,1352,-6.722689
05/31/12,1352,-11.711711
06/29/12,1352,12
07/31/12,1352,-11.607141
08/31/12,1352,0
09/28/12,1352,-3.883493
10/31/12,1352,3.0303
11/30/12,1352,2.9703
12/31/12,1352,6.730771
01/31/13,1352,12.612617
02/28/13,1352,2.439022
03/28/13,1352,6.349218
04/30/13,1352,5.303025
05/31/13,1352,-1.43885
06/28/13,1352,-11.45038
07/31/13,1352,2.58621
08/30/13,1352,-5.084747
09/30/13,1352,21.42857
10/31/13,1352,-1.47059
11/29/13,1352,4.411769
12/31/13,1352,-3.521127
01/31/14,1352,8.759129
02/28/14,1352,-16.4557
03/31/14,1352,0
04/30/14,1352,-0.78125
05/30/14,1352,-0.7874012
06/30/14,1352,5.555558
07/31/14,1352,-0.7518768
08/29/14,1352,-1.50376
09/30/14,1352,0.7633567
10/31/14,1352,-2.272725
11/28/14,1352,5.6
12/31/14,1352,-3.0303
01/30/15,1352,0
02/27/15,1352,5.511808
03/31/15,1352,4.477608
04/30/15,1352,3.759396
05/29/15,1352,3.571427
06/30/15,1352,1.379311
07/31/15,1352,1.360548
08/31/15,1352,-12.080538
09/30/15,1352,-9.022558
10/30/15,1352,10.743797
11/30/15,1352,-1.492536
12/31/15,1352,-3.0303
01/29/16,1352,-4.651165
02/29/16,1352,-10.569107
03/31/16,1352,10.909092
04/29/16,1352,1.666665
05/31/16,1352,-3.278691
06/30/16,1352,-7.758623
07/29/16,1352,2.777779
08/31/16,1352,-2.7027
09/30/16,1352,0.9259224
10/31/16,1352,2.752292
11/30/16,1352,8.849562
12/30/16,1352,4.065037
01/31/17,1352,2.34375
02/28/17,1352,-3.846157
03/31/17,1352,3.200006
04/28/17,1352,-6.976742
05/31/17,1352,0
06/30/17,1352,5.9322
07/31/17,1352,4.8
08/31/17,1352,-2.290076
09/29/17,1352,-2.380955
10/31/17,1352,0.6504059
11/30/17,1352,-4.3131
12/29/17,1352,-2.985072
01/31/18,1352,0.8547068
02/28/18,1352,-1.505017
03/29/18,1352,0
04/30/18,1352,0.5181313
05/31/18,1352,-0.6872833
06/29/18,1352,-6.711411
07/31/18,1352,-2.248204
08/31/18,1352,-6.715733
09/28/18,1352,9.037328
10/31/18,1352,-10.99099
01/29/10,1376,-0.6756783
02/26/10,1376,-3.903097
03/31/10,1376,4.341733
04/30/10,1376,12.280703
05/28/10,1376,-10.2657
06/30/10,1376,-4.924762
07/30/10,1376,8.489203
08/31/10,1376,-2.519894
09/30/10,1376,0.944674
10/29/10,1376,-2.796274
11/30/10,1376,2.054787
12/31/10,1376,7.201087
01/31/11,1376,9.885931
02/28/11,1376,-0.4624307
03/31/11,1376,-12.891984
04/29/11,1376,-0.6657779
05/31/11,1376,1.340485
06/30/11,1376,0.402689
07/29/11,1376,-0.8000016
08/31/11,1376,-2.150536
09/30/11,1376,0.2785563
10/31/11,1376,-0.4166663
11/30/11,1376,-0.1398563
12/30/11,1376,0.5673766
01/31/12,1376,-1.128352
02/29/12,1376,4.125178
03/30/12,1376,0.956285
04/30/12,1376,-3.247631
05/31/12,1376,-6.433564
06/29/12,1376,3.474319
07/31/12,1376,3.065693
08/31/12,1376,-2.266288
09/28/12,1376,0.86956
10/31/12,1376,-2.442527
11/30/12,1376,2.205884
12/31/12,1376,0.1457691
01/31/13,1376,3.784573
02/28/13,1376,10.533703
03/28/13,1376,-1.778907
04/30/13,1376,14.100909
05/31/13,1376,6.575966
06/28/13,1376,-16.75127
07/31/13,1376,15.470303
08/30/13,1376,-10.548526
09/30/13,1376,6.014156
10/31/13,1376,-1.557285
11/29/13,1376,0.11198521
12/31/13,1376,-3.167421
01/31/14,1376,3.387845
02/28/14,1376,-0.4459321
03/31/14,1376,-3.023517
04/30/14,1376,3.376019
05/30/14,1376,0.7882833
06/30/14,1376,2.154195
07/31/14,1376,5.549395
08/29/14,1376,2.10526
09/30/14,1376,1.546395
10/31/14,1376,-4.162436
11/28/14,1376,6.866956
12/31/14,1376,3.04569
01/30/15,1376,5.418718
02/27/15,1376,0.6499529
03/31/15,1376,-0.7380068
04/30/15,1376,5.48327
05/29/15,1376,7.867134
06/30/15,1376,-0.245899
07/31/15,1376,-1.807725
08/31/15,1376,-7.949793
09/30/15,1376,-7.911682
10/30/15,1376,21.87812
11/30/15,1376,0.9016395
12/31/15,1376,-1.229507
01/29/16,1376,-5.483031
02/29/16,1376,-8.287292
03/31/16,1376,1.706827
04/29/16,1376,4.4335
05/31/16,1376,25.28303
06/30/16,1376,1.675975
07/29/16,1376,18.46154
08/31/16,1376,-15.12987
09/30/16,1376,14.374995
10/31/16,1376,3.961754
11/30/16,1376,-2.704489
12/30/16,1376,3.620219
01/31/17,1376,-2.373105
02/28/17,1376,-4.416609
03/31/17,1376,0.8965492
04/28/17,1376,-2.921194
05/31/17,1376,2.239323
06/30/17,1376,-0.5471945
07/31/17,1376,-0.82531
08/31/17,1376,3.328705
09/29/17,1376,3.73832
10/31/17,1376,9.009004
11/30/17,1376,0.6536007
12/29/17,1376,-2.014971
01/31/18,1376,-3.936547
02/28/18,1376,-2.8739
03/29/18,1376,-6.340581
04/30/18,1376,7.479048
05/31/18,1376,-2.399516
06/29/18,1376,3.05624
07/31/18,1376,-4.270464
08/31/18,1376,-5.762082
09/28/18,1376,-0.06447434
10/31/18,1376,-6.193548
01/29/10,1377,-14.842028
02/26/10,1377,-1.8018
03/31/10,1377,4.67056
04/30/10,1377,5.569005
05/28/10,1377,-10.700536
06/30/10,1377,0.2608657
07/30/10,1377,0.9540319
08/31/10,1377,-3.951889
09/30/10,1377,-4.058724
10/29/10,1377,-8.436942
11/30/10,1377,3.29777
12/31/10,1377,3.886259
01/31/11,1377,8.759129
02/28/11,1377,3.166664
03/31/11,1377,-1.292408
04/29/11,1377,-3.68818
05/31/11,1377,-0.4351616
06/30/11,1377,2.626967
07/29/11,1377,-4.037804
08/31/11,1377,1.163828
09/30/11,1377,7.2711
10/31/11,1377,-6.443512
11/30/11,1377,-2.758008
12/30/11,1377,1.939058
01/31/12,1377,-2.264494
02/29/12,1377,4.735374
03/30/12,1377,1.950359
04/30/12,1377,-2.69565
05/31/12,1377,-4.46828
06/29/12,1377,1.317024
07/31/12,1377,-3.714019
08/31/12,1377,-1.639342
09/28/12,1377,0.9661794
10/31/12,1377,-1.24402
11/30/12,1377,2.469134
12/31/12,1377,1.49672
01/31/13,1377,1.290321
02/28/13,1377,12.477064
03/28/13,1377,1.14193
04/30/13,1377,7.500005
05/31/13,1377,0.07501841
06/28/13,1377,5.056596
07/31/13,1377,-2.033406
08/30/13,1377,-3.558189
09/30/13,1377,4.073787
10/31/13,1377,-1.10783
11/29/13,1377,0.8995533
12/31/13,1377,-0.149703
01/31/14,1377,-1.574212
02/28/14,1377,1.909852
03/31/14,1377,6.446779
04/30/14,1377,1.854491
05/30/14,1377,-3.641456
06/30/14,1377,2.2694
07/31/14,1377,0.07158518
08/29/14,1377,-0.71736
09/30/14,1377,0.9393096
10/31/14,1377,18.53973
11/28/14,1377,10.43644
12/31/14,1377,15.553
01/30/15,1377,2.243268
02/27/15,1377,-3.115577
03/31/15,1377,1.400411
04/30/15,1377,4.586697
05/29/15,1377,4.261363
06/30/15,1377,6.806767
07/31/15,1377,-2.309668
08/31/15,1377,-14.054293
09/30/15,1377,0.8704543
10/30/15,1377,30.45685
11/30/15,1377,-3.073931
12/31/15,1377,15.437328
01/29/16,1377,1.990914
02/29/16,1377,-5.92466
03/31/16,1377,4.077172
04/29/16,1377,-4.845363
05/31/16,1377,-4.297578
06/30/16,1377,-14.003104
07/29/16,1377,12.102472
08/31/16,1377,-9.732074
09/30/16,1377,14.65168
10/31/16,1377,18.58095
11/30/16,1377,-1.669395
12/30/16,1377,10.387444
01/31/17,1377,-2.118003
02/28/17,1377,-1.401871
03/31/17,1377,10.11058
04/28/17,1377,-0.7062137
05/31/17,1377,1.081073
06/30/17,1377,-1.5493
07/31/17,1377,-3.7196
08/31/17,1377,1.33729
09/29/17,1377,-7.38061
10/31/17,1377,7.03125
11/30/17,1377,7.814765
12/29/17,1377,5.962062
01/31/18,1377,-2.046037
02/28/18,1377,-4.492939
03/29/18,1377,-0.1344085
04/30/18,1377,8.075369
05/31/18,1377,2.366126
06/29/18,1377,2.570379
07/31/18,1377,-0.238663
08/31/18,1377,-8.014351
09/28/18,1377,8.776593
10/31/18,1377,-12.713939
01/29/10,1378,8.706463
02/26/10,1378,-2.511418
03/31/10,1378,8.899307
04/30/10,1378,16.37168
05/28/10,1378,1.698112
06/30/10,1378,-4.267162
07/30/10,1378,1.162791
08/31/10,1378,-0.3831446
09/30/10,1378,-0.5791485
10/29/10,1378,1.754391
11/30/10,1378,1.915705
12/31/10,1378,3.571427
01/31/11,1378,-0.18149
02/28/11,1378,-0.5576193
03/31/11,1378,-1.68224
04/29/11,1378,-6.930691
05/31/11,1378,0
06/30/11,1378,-0.4246294
07/29/11,1378,-6.396585
08/31/11,1378,-13.211846
09/30/11,1378,-0.7853389
10/31/11,1378,-1.319259
11/30/11,1378,-4.569894
12/30/11,1378,-4.225349
01/31/12,1378,-3.235292
02/29/12,1378,15.596331
03/30/12,1378,-7.671958
04/30/12,1378,-5.309737
05/31/12,1378,-14.641744
06/29/12,1378,1.079142
07/31/12,1378,8.185053
08/31/12,1378,-9.86842
09/28/12,1378,-7.482994
10/31/12,1378,-4.044116
11/30/12,1378,-6.69145
12/31/12,1378,6.772912
01/31/13,1378,14.552236
02/28/13,1378,-6.688964
03/28/13,1378,-1.075268
04/30/13,1378,-2.536231
05/31/13,1378,-2.230483
06/28/13,1378,-14.869886
07/31/13,1378,0.873363
08/30/13,1378,-6.465518
09/30/13,1378,10.599077
10/31/13,1378,-8.75
11/29/13,1378,3.286386
12/31/13,1378,4.54545
01/31/14,1378,2.608693
02/28/14,1378,-2.074689
03/31/14,1378,-5.084747
04/30/14,1378,1.785719
05/30/14,1378,-1.754385
06/30/14,1378,-0.8928597
07/31/14,1378,-0.9009004
08/29/14,1378,0.4524946
09/30/14,1378,-0.45045
10/31/14,1378,-6.334841
11/28/14,1378,3.883493
12/31/14,1378,-2.336448
01/30/15,1378,-0.4784703
02/27/15,1378,20.38835
03/31/15,1378,-1.209676
04/30/15,1378,-1.619434
05/29/15,1378,0
01/29/10,1379,-2.759326
02/26/10,1379,-2.4961
03/31/10,1379,4.640007
04/30/10,1379,4.801667
05/28/10,1379,-13.232321
06/30/10,1379,2.095461
07/30/10,1379,-2.90764
08/31/10,1379,11.274219
09/30/10,1379,-1.777315
10/29/10,1379,-1.61711
11/30/10,1379,-0.530225
12/31/10,1379,0.5863547
01/31/11,1379,0.05298853
02/28/11,1379,-0.2635717
03/31/11,1379,1.479912
04/29/11,1379,-2.324325
05/31/11,1379,-1.494187
06/30/11,1379,-0.3952563
07/29/11,1379,0.170064
08/31/11,1379,-2.376908
09/30/11,1379,4.811597
10/31/11,1379,-9.288096
11/30/11,1379,0.36608
12/30/11,1379,2.249241
01/31/12,1379,-0.11890531
02/29/12,1379,2.191949
03/30/12,1379,3.76811
04/30/12,1379,-1.147449
05/31/12,1379,-3.134066
06/29/12,1379,-3.746223
07/31/12,1379,-3.766477
08/31/12,1379,-0.2609253
09/28/12,1379,8.698487
10/31/12,1379,-3.389829
11/30/12,1379,4.904461
12/31/12,1379,2.853668
01/31/13,1379,1.2987
02/28/13,1379,3.846157
03/28/13,1379,4.2735
04/30/13,1379,5.328095
05/31/13,1379,-4.259849
06/28/13,1379,-2.977526
07/31/13,1379,1.273882
08/30/13,1379,-2.823263
09/30/13,1379,3.951192
10/31/13,1379,5.902195
11/29/13,1379,3.222394
12/31/13,1379,1.074719
01/31/14,1379,-4.4557
02/28/14,1379,5.929923
03/31/14,1379,11.80662
04/30/14,1379,-2.7027
05/30/14,1379,-4.873294
06/30/14,1379,2.868855
07/31/14,1379,-2.290839
08/29/14,1379,-1.503009
09/30/14,1379,1.220751
10/31/14,1379,2.929294
11/28/14,1379,-1.67076
12/31/14,1379,0
01/30/15,1379,8.295858
02/27/15,1379,15.769588
03/31/15,1379,-6.769979
04/30/15,1379,-3.803134
05/29/15,1379,9.585249
06/30/15,1379,5.508828
07/31/15,1379,-1.275408
08/31/15,1379,-11.18288
09/30/15,1379,-3.518933
10/30/15,1379,9.740257
11/30/15,1379,-1.352495
12/31/15,1379,-0.1713812
01/29/16,1379,-1.288658
02/29/16,1379,-11.662316
03/31/16,1379,12.118233
04/29/16,1379,-4.744852
05/31/16,1379,-4.3703
06/30/16,1379,-5.614037
07/29/16,1379,0.4208326
08/31/16,1379,-7.386065
09/30/16,1379,2.296925
10/31/16,1379,12.555063
11/30/16,1379,3.078496
12/30/16,1379,4.977596
01/31/17,1379,-3.129447
02/28/17,1379,7.1499
03/31/17,1379,-5.338245
04/28/17,1379,0.6578922
05/31/17,1379,-4.0631
06/30/17,1379,-1.496261
07/31/17,1379,-0.4050612
08/31/17,1379,0.1016736
09/29/17,1379,0.8708954
10/31/17,1379,0.9698868
11/30/17,1379,1.713705
12/29/17,1379,1.635277
01/31/18,1379,-1.755244
02/28/18,1379,2.174962
03/29/18,1379,-1.371807
04/30/18,1379,-5.061424
05/31/18,1379,5.227745
06/29/18,1379,-3.230542
07/31/18,1379,0.4552364
08/31/18,1379,-3.977847
09/28/18,1379,2.14659
10/31/18,1379,-0.7212758
01/29/10,1380,-4.705882
02/26/10,1380,0.9523869
03/31/10,1380,0.9433866
04/30/10,1380,-1.411766
05/28/10,1380,-3.981262
06/30/10,1380,-7.317072
07/30/10,1380,3.15789
08/31/10,1380,2.040815
09/30/10,1380,-2.5
10/29/10,1380,2.564108
11/30/10,1380,0.4999995
12/31/10,1380,1.74129
01/31/11,1380,0.2444983
02/28/11,1380,4.878044
03/31/11,1380,-6.744188
04/29/11,1380,-0.7317066
05/31/11,1380,-1.719904
06/30/11,1380,-3.75
07/29/11,1380,2.040815
08/31/11,1380,-2
09/30/11,1380,-7.397962
10/31/11,1380,4.683197
11/30/11,1380,-3.947371
12/30/11,1380,7.397258
01/31/12,1380,2.040815
02/29/12,1380,-0.999999
03/30/12,1380,3.0303
04/30/12,1380,-1.234567
05/31/12,1380,-6.75
06/29/12,1380,-1.028275
07/31/12,1380,14.285719
08/31/12,1380,-12.272728
09/28/12,1380,-0.9756088
10/31/12,1380,-11.083746
11/30/12,1380,-1.897019
12/31/12,1380,6.90608
01/31/13,1380,7.235146
02/28/13,1380,-0.2421319
03/28/13,1380,2.669907
04/30/13,1380,-3.571427
05/31/13,1380,-3.456789
06/28/13,1380,0.2506256
07/31/13,1380,0.7500052
08/30/13,1380,-3.970224
09/30/13,1380,5.684757
10/31/13,1380,-0.977993
11/29/13,1380,-0.9876549
12/31/13,1380,0.2493739
01/31/14,1380,6.716418
02/28/14,1380,2.564108
03/31/14,1380,-8.409089
04/30/14,1380,3.250003
05/30/14,1380,-6.537533
06/30/14,1380,4.145074
07/31/14,1380,5.72139
08/29/14,1380,4.895103
09/30/14,1380,-3.555554
10/31/14,1380,-0.9216607
11/28/14,1380,2.325583
12/31/14,1380,3.409088
01/30/15,1380,2.1978
02/27/15,1380,5.376339
03/31/15,1380,1.632655
04/30/15,1380,-2.204406
05/29/15,1380,-0.6147563
06/30/15,1380,-0.6185591
07/31/15,1380,7.261407
08/31/15,1380,-6.963247
09/30/15,1380,4.158008
10/30/15,1380,1.596808
11/30/15,1380,-0.5893886
12/31/15,1380,2.7668
01/29/16,1380,1.346159
02/29/16,1380,6.641364
03/31/16,1380,-2.846974
04/29/16,1380,-2.636534
05/31/16,1380,-0.7736921
06/30/16,1380,3.50877
07/29/16,1380,-2.071565
08/31/16,1380,-2.692306
09/30/16,1380,1.185775
10/31/16,1380,5.46875
11/30/16,1380,-3.220034
12/30/16,1380,7.208872
01/31/17,1380,2.241385
02/28/17,1380,9.337866
03/31/17,1380,-4.347825
04/28/17,1380,-1.857585
05/31/17,1380,-3.815579
06/30/17,1380,4.6281
07/31/17,1380,2.685618
08/31/17,1380,-7.384616
09/29/17,1380,0.666666
10/31/17,1380,4.801321
11/30/17,1380,-2.021772
12/29/17,1380,0.156498
01/31/18,1380,13.125
02/28/18,1380,-0.9628594
03/29/18,1380,5.972219
04/30/18,1380,-4.74934
05/31/18,1380,-3.878117
06/29/18,1380,6.461084
07/31/18,1380,1.103449
08/31/18,1380,-3.956342
09/28/18,1380,-0.2808988
10/31/18,1380,-0.8450687
01/29/10,1381,5.263162
02/26/10,1381,-1.923078
03/31/10,1381,3.006542
04/30/10,1381,1.781166
05/28/10,1381,-1.125
06/30/10,1381,-9.292036
07/30/10,1381,-4.680848
08/31/10,1381,4.166663
09/30/10,1381,3.285718
10/29/10,1381,-5.255878
11/30/10,1381,2.91971
12/31/10,1381,-2.695036
01/31/11,1381,2.040815
02/28/11,1381,-0.437957
03/31/11,1381,4.105568
04/29/11,1381,1.408446
05/31/11,1381,4.166663
06/30/11,1381,-2.333337
07/29/11,1381,2.459013
08/31/11,1381,2.666664
09/30/11,1381,-3.896105
10/31/11,1381,2.567565
11/30/11,1381,0.13175
12/30/11,1381,1.315784
01/31/12,1381,-0.2597392
02/29/12,1381,-1.041669
03/30/12,1381,8.815789
04/30/12,1381,0.3627539
05/31/12,1381,3.012049
06/29/12,1381,-10.818714
07/31/12,1381,1.733339
08/31/12,1381,-1.7038
09/28/12,1381,-2.435726
10/31/12,1381,0.9708762
11/30/12,1381,-0.5494535
12/31/12,1381,2.209949
01/31/13,1381,-0.405407
02/28/13,1381,7.765663
03/28/13,1381,1.517069
04/30/13,1381,10.585308
05/31/13,1381,-0.6756783
06/28/13,1381,-14
07/31/13,1381,1.351357
08/30/13,1381,-1.733333
09/30/13,1381,3.120756
10/31/13,1381,-1.710528
11/29/13,1381,1.773536
12/31/13,1381,-0.1340508
01/31/14,1381,4.966438
02/28/14,1381,-5.389219
03/31/14,1381,0.2531648
04/30/14,1381,0.5063295
05/30/14,1381,3.904283
06/30/14,1381,-2.848488
07/31/14,1381,67.9341
08/29/14,1381,-2.417189
09/30/14,1381,-5.504584
10/31/14,1381,11.165047
11/28/14,1381,4.769874
12/31/14,1381,-4.472846
01/30/15,1381,32.6087
02/27/15,1381,-4.359859
03/31/15,1381,6.439936
04/30/15,1381,38.95105
05/29/15,1381,4.612458
06/30/15,1381,5.227268
07/31/15,1381,10.917032
08/31/15,1381,-15.74803
09/30/15,1381,-3.691435
10/30/15,1381,23.29239
11/30/15,1381,1.434839
12/31/15,1381,-5.068761
01/29/16,1381,-0.453794
02/29/16,1381,-5.926233
03/31/16,1381,9.163
04/29/16,1381,-8.495933
05/31/16,1381,-4.442472
06/30/16,1381,-14.193553
07/29/16,1381,-6.114721
08/31/16,1381,-1.325649
09/30/16,1381,-3.314286
10/31/16,1381,7.801414
11/30/16,1381,3.457892
12/30/16,1381,2.911055
01/31/17,1381,4.976428
02/28/17,1381,5.185914
03/31/17,1381,9.813952
04/28/17,1381,8.510637
05/31/17,1381,15.340257
;;;;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Add a RETAIN statement:

 

data test;
set test; 
by ticker Date; 
retain cumuret;
if first.ticker then cumuret = 0; 
else cumuret = (1+cumuret) * (1+return/100) - 1; 
run;
PG

View solution in original post

1 REPLY 1
PGStats
Opal | Level 21

Add a RETAIN statement:

 

data test;
set test; 
by ticker Date; 
retain cumuret;
if first.ticker then cumuret = 0; 
else cumuret = (1+cumuret) * (1+return/100) - 1; 
run;
PG

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 758 views
  • 1 like
  • 2 in conversation