[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: AW: For each fund-asset pair I have observations on some periods, and want have them on each possible period... |

Date |
Fri, 24 Jul 2009 17:36:09 +0200 |

<> Here is an example for "Stata Chris" using -fillin- ************* clear* set obs 5 // fund id gen fundid=_n lab var fundid "Fund ID" // expand to 4 of time periods expand 4 bys fundid: gen time=_n // 3 assets expand 3 bys fundid time:/* */ gen asset=_n // generate value and holdings gen quantity=/* */ rnormal() gen value=/* */ 100*rnormal() // inducing missings drop if runiform()<0.1 /* recover "full" dataset with -fillin- */ fillin fundid time asset //whenever filled in: //really zero //important to distinguish //from "real" missings replace quantity=0 if _fillin==1 //get the stock of holdings bys fundid asset (time): /* */ gen holding=sum(quantity) compress list fundid time asset /* */ quantity holding, noobs /* */ sepby(fundid asset) //get rid of aux var drop _fillin ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Stata Chris Gesendet: Freitag, 24. Juli 2009 17:03 An: statalist@hsphsun2.harvard.edu Betreff: st: For each fund-asset pair I have observations on some periods, and want have them on each possible period... Hi Statalisters, I have the following challenge: I have a dataset that gives me for each fund-asset-period triple the quantity and value of holdings (i.e. how much of asset j did fund i hold in period t). >From this, I have for each such triple generated the flow (i.e. how much did the fund buy or sell of a certain asset) from last period until now. The problem is that the original dataset does not list holdings or size zero. Consequence: If a fund held say 500 units of an asset and then sold all of these, the respective fund-asset-period observation for the next period does not exist, so when I compute the flow I get a missing observation, although it should say flow=-500. Analogously, if the fund has bought 500 units of an assets after previously holdings of zero, I would like to have Stata tell me that the flow equals +500, but instead it will tell me that the flow is missing. So I figured the best thing to do, to be on the safe side, would be to make sure that for each fund-asset pair I have observations on all periods, rather than just on those for which holdings were listed. In upshot: My data are currently in long form, with each observation being a unique fund-asset-period triple. However, for each fund-asset pair I have observations on some but not all of up to 60 periods. The question is: How can I add observations such that for each pair there is an observation on each of the 60 periods (some of which may only have missing values, but they need to be listed)? Many thanks for your help! Chris * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: For each fund-asset pair I have observations on some periods, and want have them on each possible period...***From:*Stata Chris <statachris@gmail.com>

- Prev by Date:
**st: Adding a Reference Point to a -tabplot- Graph** - Next by Date:
**st: NLSUR and TEST linear hypotheses for the parameter** - Previous by thread:
**st: AW: For each fund-asset pair I have observations on some periods, and want have them on each possible period...** - Next by thread:
**Re: st: AW: For each fund-asset pair I have observations on some periods, and want have them on each possible period...** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |