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]

Re: st: Collapse - How does it collapse


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

I findout the reason for not reducing the # of observations. Since I am asking stata to collapse based on both id (identifier) and newdate (date)  and each id takes on any special date only once. If I remove id from collapse command the number of observation reduced considerably to about 2000. Now the problem is, how can I keep the id in the collapsed date in as is format and rest of the variables based on id and valdate as means. Any help will be highly appreciated. 

Dawood
----- Original Message -----
From: Dawood Ashraf <[email protected]>
To: "[email protected]" <[email protected]>
Cc: 
Sent: Saturday, June 25, 2011 12:14:48 PM
Subject: st: Collapse - How does it collapse

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?searchhttp://www.stata.com/support/statalist/faqhttp://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/


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