I am having trouble using forvalues to generate a new variable.
My problem is this:
I have a variable that contains the value of an option grant (in $). Following this, there are two variables that contain information on how it vests. The first, vestlowgrant shows the initial period it vests. The second, vesthighgrant, shows the latest period. These are months. For example, if vestlowgrant is 12 and vesthighgrant is 48, that means that the grant vests across 48 months in 12 month increments. If grant is value (grantdatefv) is $1,000,000 this means that $250,000 vests after 12 months, another $250,000 after 24, another $250,000 after 36 and the remaining $250,000 after 48 months.
I am trying to calculate the so called duration. Duration is calculated by multiplying vesting schedule by the time. If we convert months into years, this grant's components vest 1, 2, 3 and 4 years, respectively.
What I'm trying to do is to use these variables to calculate the sum of these values automatically.
In this case, what I want to do is to calculate duration = (250,000)*1 + (250,000)*2 + (250,000)*3 + (250,000)*4.
Basically, I though of using forvalue to loop through years 1-4 in 1 increment and then multiply the grant's one year value to get the duration and sum it up. However, I couldn't get it to work since every observation has a different vesting schedule, so I couldn't figure out how to define forvalues values and putting the vestlowgrant and vesthighgrant into `vestlowgrant' and `vesthighgrant' didn't work.
Any help would be extremely appreciated!
Code:
* Example generated by -dataex-. For more info, type help dataex clear cik fiscalyear fiscalmonth awardtype grantdatefv vestlowgrant vesthighgrant "0001707753" 2017 4 "Option" 1134880 19 67 "0001707753" 2017 4 "Option" 3462657 19 67 "0001707753" 2017 4 "Option" 7514361 1 49 "0001707753" 2019 4 "Option" 4872356 31 78 "0001707753" 2019 4 "Option" 2669951 31 78 "0001707753" 2019 4 "Option" 1067980 31 78 "0001707753" 2019 4 "Option" 1067980 31 78 end
0 Response to Generating new variable using forvalues
Post a Comment