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