Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Collapse - How does it collapse


From   Dawood Ashraf <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Collapse - How does it collapse
Date   Sat, 25 Jun 2011 02:14:48 -0700 (PDT)

Dear Statalist,
 
I have historical daily price data of mutual funds and I am trying to 'collapse' it in monthly. I followed the collapse command as suggested in the manual and I believe this shoudl work. However, the number of observations does not change that I believe should after collapse from daily to monthly data. 
 
.  generate newdate = date(vdate, "MDY")          /this converts the string valuation date to non-string)?
. format newdate %tm                                     /This converts date from %td to %tm - the possible error could be here?
. describe
Contains data from D:\Mutual Fund Data\MutualFundData_clean.dta
  obs:       116,251                          
 vars:            10                          25 Jun 2011 00:32
 size:    55,800,480 (89.4% of memory free)
---------------------------------------------------------------------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
---------------------------------------------------------------------------------------------------------------------------------------------
name            str143 %143s                  Fund Name
manager         str200 %200s                  Fund Manager
type            str100 %100s                  Type of Fund
nav             double %8.0g                  Net Asset Value
price           float  %8.0g                  Unit Price
vdate           str10  %10s                   Valuation Date
id              int    %8.0g                  Identifier
valdate         float  %9.0g                  
sharia          byte   %8.0g                  type==Shari'ah Compliant
newdate         float  %tm                    
---------------------------------------------------------------------------------------------------------------------------------------------
Sorted by:  id  valdate
     Note:  dataset has changed since last saved
 
. collapse (mean) nav price sharia, by (newdate id)
 
. su price
    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       price |    116251    130.5486    818.1193      .0712     184587
 
If you see here number of observations are still 116251. The number should reduce since the data is monthly now.
Please help.
Regards
 
 
Dawood

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index