Dear Madam/Sir,
I would like to get the cumulative sum for five executives by firm and year as below.
firm year executive id shrown_tot_pct
001004 | 2009 | 09249 | 3.861 |
001004 | 2009 | 09252 | 0.694 |
001004 | 2009 | 23781 | 0.458 |
001004 | 2009 | 33979 | 0.286 |
001004 | 2009 | 36199 | 0.121 |
001004 | 2010 | 09249 | 3.833 |
001004 | 2010 | 09252 | 0.897 |
001004 | 2010 | 33979 | 0.361 |
001004 | 2010 | 36199 | 0.177 |
001004 | 2010 | 41787 | 0.265 |
I used the following code, but I did not get the desired results (null).
proc sort data=y1; by gvkey year; run;
data y2; set y1;
by gvkey year;
retain sumown;
if first.gvkey then sumown=shrown_tot_pct;
else sumown=sumown+shrown_tot_pct; run;
Any advice will be highly appreciated.
Thanks
Joon1
Description, table and code do not match.
Please post data in usable form and take care that you are using the same names in description, data and code.
Thank you! I appreciate it.
Joon1
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.