Hello
I would like some assistance with generating newvar [XIRR] from returned r-class command.
I am using the finxirr (command for a single cash-flow series) package from http://www.stata.com/users/kcrow
The sample data is:
id amount date
1 -10000 01/01/2008
1 2750 01/03/2008
1 4250 30/10/2008
1 3250 15/02/2009
1 2750 01/04/2009
2 -12000 01/01/2008
2 2750 01/03/2008
2 4250 30/10/2008
2 3250 15/02/2009
2 2750 01/04/2009
I require the return to be separated by the var_id, so I have used the 'by id:' command
CODE:
. by id: finxirr amount
The result is displayed in the results window as follows:
--------------------------------------------------------------------------------------------------------------------------------------------------------------
-> id = 1
XIRR, Extented internal rate of return = .373
--------------------------------------------------------------------------------------------------------------------------------------------------------------
-> id = 2
XIRR, Extented internal rate of return = .0994
I have used the return list command to display scalar r(xirr)
. return list
scalars:
r(xirr) = .0993987644807661
And then gen command to create the newvar:
. generate XIRR = `r(xirr)'
However, the variable for both id1 & id2 display the result for id = 2, as shown below:
id amount date XIRR
1 -10000 01/01/2008 .0993988
1 2750 01/03/2008 .0993988
1 4250 30/10/2008 .0993988
1 3250 15/02/2009 .0993988
1 2750 01/04/2009 .0993988
2 -12000 01/01/2008 .0993988
2 2750 01/03/2008 .0993988
2 4250 30/10/2008 .0993988
2 3250 15/02/2009 .0993988
2 2750 01/04/2009 .0993988
I have read the stored results and return stored results stata PDF Guides and searched the forums and understand that "returned results from previous commands are replaced by subsequent commands of the same class".
I have searched the forums and could not see an example of how to run the return list command when the results are provided in the format above (id separated by dashed line)
I require id1 XIRR variable to display .373 - it's returned 'r(xirr)' result while XIRR for id2 maintains its 'r(xirr)' result.
Any assistance would be greatly appreciated.
Mark
Related Posts with Generating new variable from r-class command that produces multiple returns (as a result of using 'by:' command)
Multiple Legends and Reducing Variables with Four Panes in CoefplotHey there Stata users, I am trying to plot the results for a select number of independent variables…
Replacing values of one variable by specific value in anotherHi All, I have data that resembles the following: Code: * Example generated by -dataex-. To inst…
variable does not uniquely identify observations in the using dataHi I'm working with two data bases but there they don't have the same observations. The first one be…
combine csv filesHi all, I have 1460 file.csv, each one of these files provide information on price, brand and fuel o…
Why dummy variable is not correct?Dear Stata users, I am trying to create two dummy variables respecting a few conditions, but for so…
Subscribe to:
Post Comments (Atom)
0 Response to Generating new variable from r-class command that produces multiple returns (as a result of using 'by:' command)
Post a Comment