Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • quarterly data--calculate the standard deviation of quarterly data over the past four years

    Good morning,

    I am currently working with the quarterly return data and want to calculate the standard deviation of the return over the past four years.

    I have no clue how to construct and calculate. Any one can help?

    Thanks in advance!

    Best wishes,

    Shuhui

  • #2
    Check -dataex- and post some example of your data. At this point it is not clear, do you have aggregate returns (one time series), multiple firm/industry returns (like a panel), etc., so it will be hard for anybody to offer any help.

    Comment


    • #3
      Hi Joro,

      Thanks for your reply. Here is the sample. I aim to calculate the standard deviation for every firm in every four years (which are 16 quarters). So standard deviation in 2004, it will be used 2001-2004 data to calculate. For 2005, it will be used 2002-2005, so on so forth. Hope this can be clearer.

      Thanks,

      Shuhui
      Attached Files

      Comment


      • #4
        https://www.statalist.org/forums/help#stata explains what you should do (use dataex as urged) and should emphatically not do (post spreadsheet files; would you post .dta files to an Excel forum?).

        Please study it carefully.

        Comment


        • #5
          I think this should do it (I pasted the observations from your excel file manually):

          Code:
          . clear
          
          . *(5 variables, 32 observations pasted into data editor)
          
          . gen date = yq( fyearq , fqtr )
          
          . format date %tq
          
          . tsset gvkey date
                 panel variable:  gvkey (strongly balanced)
                  time variable:  date, 2001q1 to 2008q4
                          delta:  1 quarter
          
          . rolling sdroa=r(sd), window(16) clear keep(date) : summ roa
          (running summarize on estimation sample)
          
          -> gvkey = 1004
          
          Rolling replications (17)
          ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
          .................
          
          . list, clean
          
                 gvkey    start      end     date      sdroa  
            1.    1004   2001q1   2004q4   2004q4   .0197199  
            2.    1004   2001q2   2005q1   2005q1   .0198941  
            3.    1004   2001q3   2005q2   2005q2   .0056534  
            4.    1004   2001q4   2005q3   2005q3   .0059014  
            5.    1004   2002q1   2005q4   2005q4   .0063122  
            6.    1004   2002q2   2006q1   2006q1   .0061172  
            7.    1004   2002q3   2006q2   2006q2   .0063928  
            8.    1004   2002q4   2006q3   2006q3   .0067442  
            9.    1004   2003q1   2006q4   2006q4   .0055481  
           10.    1004   2003q2   2007q1   2007q1    .004964  
           11.    1004   2003q3   2007q2   2007q2   .0048261  
           12.    1004   2003q4   2007q3   2007q3   .0046276  
           13.    1004   2004q1   2007q4   2007q4   .0044529  
           14.    1004   2004q2   2008q1   2008q1   .0039159  
           15.    1004   2004q3   2008q2   2008q2    .003859  
           16.    1004   2004q4   2008q3   2008q3    .003196  
           17.    1004   2005q1   2008q4   2008q4     .00302

          Comment


          • #6
            Here is an asrol solution. asrol can be downloaded from ssc
            Code:
            ssc install asrol
            
            import excel "C:\temp\ROA sample.xlsx", sheet("Sheet1") firstrow
            
            gen qofd = yq( fyearq , fqtr )
            
            format qofd %tq
            
            bys gvkey: asrol ROA, stat(sd) window(qofd 16)
            
            list gvkey ROA qofd sd16_ROA in 1/20
            
                 +----------------------------------------+
                 | gvkey         ROA     qofd    sd16_ROA |
                 |----------------------------------------|
              1. |  1004    .0006407   2001q1           . |
              2. |  1004   -.0762859   2001q2   .05439532 |
              3. |  1004   -.0033156   2001q3    .0433167 |
              4. |  1004   -.0037328   2001q4   .03712734 |
              5. |  1004   -.0067488   2002q1    .0327507 |
                 |----------------------------------------|
              6. |  1004    -.000911   2002q2   .03010192 |
              7. |  1004    .0009004   2002q3   .02813344 |
              8. |  1004   -.0109507   2002q4   .02605453 |
              9. |  1004   -.0029512   2003q1   .02458093 |
             10. |  1004     .001375   2003q2   .02352916 |
                 |----------------------------------------|
             11. |  1004    .0027897   2003q3    .0226626 |
             12. |  1004    .0036262   2003q4   .02191403 |
             13. |  1004     .003269   2004q1   .02121112 |
             14. |  1004    .0068066   2004q2   .02071512 |
             15. |  1004     .003668   2004q3   .02012049 |
                 |----------------------------------------|
             16. |  1004    .0078295   2004q4    .0197199 |
             17. |  1004    .0069383   2005q1   .01989408 |
             18. |  1004      .00986   2005q2    .0056534 |
             19. |  1004    .0097319   2005q3   .00590139 |
             20. |  1004    .0131781   2005q4   .00631223 |
                 +----------------------------------------+
            Please note that asrol is blinking fast compared to the rolling command and performance difference is huge in big data sets.
            Regards
            --------------------------------------------------
            Attaullah Shah, PhD.
            Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
            FinTechProfessor.com
            https://asdocx.com
            Check out my asdoc program, which sends outputs to MS Word.
            For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

            Comment


            • #7
              See below for how to give us data, with dataex.

              Variations on a theme... Yet another way to do it, here with rangestat (SSC).

              Some points of wider interest:

              1. For windows ideally of length #, it can be interesting and useful to keep track of the number of values used.

              2. There is some flexibility over specification of windows. Here it's the present value and (at most) the previous 15, but that is just an example.

              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input int gvkey str9 datadate int fyearq byte fqtr float roa
              1004 "31-Aug-01" 2001 1  .0006407
              1004 "30-Nov-01" 2001 2 -.0762859
              1004 "28-Feb-02" 2001 3 -.0033156
              1004 "31-May-02" 2001 4 -.0037328
              1004 "31-Aug-02" 2002 1 -.0067488
              1004 "30-Nov-02" 2002 2  -.000911
              1004 "28-Feb-03" 2002 3  .0009004
              1004 "31-May-03" 2002 4 -.0109507
              1004 "31-Aug-03" 2003 1 -.0029512
              1004 "30-Nov-03" 2003 2   .001375
              1004 "29-Feb-04" 2003 3  .0027897
              1004 "31-May-04" 2003 4  .0036262
              1004 "31-Aug-04" 2004 1   .003269
              1004 "30-Nov-04" 2004 2  .0068066
              1004 "28-Feb-05" 2004 3   .003668
              1004 "31-May-05" 2004 4  .0078295
              1004 "31-Aug-05" 2005 1  .0069383
              1004 "30-Nov-05" 2005 2    .00986
              1004 "28-Feb-06" 2005 3  .0097319
              1004 "31-May-06" 2005 4  .0131781
              1004 "31-Aug-06" 2006 1  .0120392
              1004 "30-Nov-06" 2006 2  .0137538
              1004 "28-Feb-07" 2006 3  .0150972
              1004 "31-May-07" 2006 4  .0167164
              1004 "31-Aug-07" 2007 1    .01407
              1004 "30-Nov-07" 2007 2  .0156996
              1004 "29-Feb-08" 2007 3  .0150699
              1004 "31-May-08" 2007 4  .0161827
              1004 "31-Aug-08" 2008 1  .0110863
              1004 "30-Nov-08" 2008 2  .0075303
              1004 "28-Feb-09" 2008 3  .0123014
              1004 "31-May-09" 2008 4   .010291
              end
              
              gen qdate = yq(fyearq, fqtr)
              format %tq qdate
              
              rangestat (count) roa (sd) roa, int(qdate -15 0) by(gvkey)
              
              list, sep(0)
              
                   +------------------------------------------------------------------------------+
                   | gvkey    datadate   fyearq   fqtr        roa    qdate   roa_co~t      roa_sd |
                   |------------------------------------------------------------------------------|
                1. |  1004   31-Aug-01     2001      1    .000641   2001q1          1           . |
                2. |  1004   30-Nov-01     2001      2   -.076286   2001q2          2   .05439532 |
                3. |  1004   28-Feb-02     2001      3   -.003316   2001q3          3    .0433167 |
                4. |  1004   31-May-02     2001      4   -.003733   2001q4          4   .03712734 |
                5. |  1004   31-Aug-02     2002      1   -.006749   2002q1          5    .0327507 |
                6. |  1004   30-Nov-02     2002      2   -.000911   2002q2          6   .03010192 |
                7. |  1004   28-Feb-03     2002      3      .0009   2002q3          7   .02813344 |
                8. |  1004   31-May-03     2002      4   -.010951   2002q4          8   .02605452 |
                9. |  1004   31-Aug-03     2003      1   -.002951   2003q1          9   .02458093 |
               10. |  1004   30-Nov-03     2003      2    .001375   2003q2         10   .02352916 |
               11. |  1004   29-Feb-04     2003      3     .00279   2003q3         11    .0226626 |
               12. |  1004   31-May-04     2003      4    .003626   2003q4         12   .02191403 |
               13. |  1004   31-Aug-04     2004      1    .003269   2004q1         13   .02121112 |
               14. |  1004   30-Nov-04     2004      2    .006807   2004q2         14   .02071512 |
               15. |  1004   28-Feb-05     2004      3    .003668   2004q3         15   .02012049 |
               16. |  1004   31-May-05     2004      4     .00783   2004q4         16    .0197199 |
               17. |  1004   31-Aug-05     2005      1    .006938   2005q1         16   .01989408 |
               18. |  1004   30-Nov-05     2005      2     .00986   2005q2         16    .0056534 |
               19. |  1004   28-Feb-06     2005      3    .009732   2005q3         16   .00590139 |
               20. |  1004   31-May-06     2005      4    .013178   2005q4         16   .00631223 |
               21. |  1004   31-Aug-06     2006      1    .012039   2006q1         16   .00611721 |
               22. |  1004   30-Nov-06     2006      2    .013754   2006q2         16    .0063928 |
               23. |  1004   28-Feb-07     2006      3    .015097   2006q3         16   .00674418 |
               24. |  1004   31-May-07     2006      4    .016716   2006q4         16   .00554812 |
               25. |  1004   31-Aug-07     2007      1     .01407   2007q1         16   .00496402 |
               26. |  1004   30-Nov-07     2007      2      .0157   2007q2         16   .00482606 |
               27. |  1004   29-Feb-08     2007      3     .01507   2007q3         16   .00462757 |
               28. |  1004   31-May-08     2007      4    .016183   2007q4         16   .00445286 |
               29. |  1004   31-Aug-08     2008      1    .011086   2008q1         16   .00391594 |
               30. |  1004   30-Nov-08     2008      2     .00753   2008q2         16   .00385901 |
               31. |  1004   28-Feb-09     2008      3    .012301   2008q3         16   .00319603 |
               32. |  1004   31-May-09     2008      4    .010291   2008q4         16   .00301998 |
                   +------------------------------------------------------------------------------+

              Comment


              • #8
                Originally posted by Joro Kolev View Post
                I think this should do it (I pasted the observations from your excel file manually):

                Code:
                . clear
                
                . *(5 variables, 32 observations pasted into data editor)
                
                . gen date = yq( fyearq , fqtr )
                
                . format date %tq
                
                . tsset gvkey date
                panel variable: gvkey (strongly balanced)
                time variable: date, 2001q1 to 2008q4
                delta: 1 quarter
                
                . rolling sdroa=r(sd), window(16) clear keep(date) : summ roa
                (running summarize on estimation sample)
                
                -> gvkey = 1004
                
                Rolling replications (17)
                ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
                .................
                
                . list, clean
                
                gvkey start end date sdroa
                1. 1004 2001q1 2004q4 2004q4 .0197199
                2. 1004 2001q2 2005q1 2005q1 .0198941
                3. 1004 2001q3 2005q2 2005q2 .0056534
                4. 1004 2001q4 2005q3 2005q3 .0059014
                5. 1004 2002q1 2005q4 2005q4 .0063122
                6. 1004 2002q2 2006q1 2006q1 .0061172
                7. 1004 2002q3 2006q2 2006q2 .0063928
                8. 1004 2002q4 2006q3 2006q3 .0067442
                9. 1004 2003q1 2006q4 2006q4 .0055481
                10. 1004 2003q2 2007q1 2007q1 .004964
                11. 1004 2003q3 2007q2 2007q2 .0048261
                12. 1004 2003q4 2007q3 2007q3 .0046276
                13. 1004 2004q1 2007q4 2007q4 .0044529
                14. 1004 2004q2 2008q1 2008q1 .0039159
                15. 1004 2004q3 2008q2 2008q2 .003859
                16. 1004 2004q4 2008q3 2008q3 .003196
                17. 1004 2005q1 2008q4 2008q4 .00302
                Hi Joro,

                Really appreciate your help!! It works for me!!

                Thanks again.

                Shuhui

                Comment


                • #9
                  Originally posted by Nick Cox View Post
                  See below for how to give us data, with dataex.

                  Variations on a theme... Yet another way to do it, here with rangestat (SSC).

                  Some points of wider interest:

                  1. For windows ideally of length #, it can be interesting and useful to keep track of the number of values used.

                  2. There is some flexibility over specification of windows. Here it's the present value and (at most) the previous 15, but that is just an example.

                  Code:
                  * Example generated by -dataex-. To install: ssc install dataex
                  clear
                  input int gvkey str9 datadate int fyearq byte fqtr float roa
                  1004 "31-Aug-01" 2001 1 .0006407
                  1004 "30-Nov-01" 2001 2 -.0762859
                  1004 "28-Feb-02" 2001 3 -.0033156
                  1004 "31-May-02" 2001 4 -.0037328
                  1004 "31-Aug-02" 2002 1 -.0067488
                  1004 "30-Nov-02" 2002 2 -.000911
                  1004 "28-Feb-03" 2002 3 .0009004
                  1004 "31-May-03" 2002 4 -.0109507
                  1004 "31-Aug-03" 2003 1 -.0029512
                  1004 "30-Nov-03" 2003 2 .001375
                  1004 "29-Feb-04" 2003 3 .0027897
                  1004 "31-May-04" 2003 4 .0036262
                  1004 "31-Aug-04" 2004 1 .003269
                  1004 "30-Nov-04" 2004 2 .0068066
                  1004 "28-Feb-05" 2004 3 .003668
                  1004 "31-May-05" 2004 4 .0078295
                  1004 "31-Aug-05" 2005 1 .0069383
                  1004 "30-Nov-05" 2005 2 .00986
                  1004 "28-Feb-06" 2005 3 .0097319
                  1004 "31-May-06" 2005 4 .0131781
                  1004 "31-Aug-06" 2006 1 .0120392
                  1004 "30-Nov-06" 2006 2 .0137538
                  1004 "28-Feb-07" 2006 3 .0150972
                  1004 "31-May-07" 2006 4 .0167164
                  1004 "31-Aug-07" 2007 1 .01407
                  1004 "30-Nov-07" 2007 2 .0156996
                  1004 "29-Feb-08" 2007 3 .0150699
                  1004 "31-May-08" 2007 4 .0161827
                  1004 "31-Aug-08" 2008 1 .0110863
                  1004 "30-Nov-08" 2008 2 .0075303
                  1004 "28-Feb-09" 2008 3 .0123014
                  1004 "31-May-09" 2008 4 .010291
                  end
                  
                  gen qdate = yq(fyearq, fqtr)
                  format %tq qdate
                  
                  rangestat (count) roa (sd) roa, int(qdate -15 0) by(gvkey)
                  
                  list, sep(0)
                  
                  +------------------------------------------------------------------------------+
                  | gvkey datadate fyearq fqtr roa qdate roa_co~t roa_sd |
                  |------------------------------------------------------------------------------|
                  1. | 1004 31-Aug-01 2001 1 .000641 2001q1 1 . |
                  2. | 1004 30-Nov-01 2001 2 -.076286 2001q2 2 .05439532 |
                  3. | 1004 28-Feb-02 2001 3 -.003316 2001q3 3 .0433167 |
                  4. | 1004 31-May-02 2001 4 -.003733 2001q4 4 .03712734 |
                  5. | 1004 31-Aug-02 2002 1 -.006749 2002q1 5 .0327507 |
                  6. | 1004 30-Nov-02 2002 2 -.000911 2002q2 6 .03010192 |
                  7. | 1004 28-Feb-03 2002 3 .0009 2002q3 7 .02813344 |
                  8. | 1004 31-May-03 2002 4 -.010951 2002q4 8 .02605452 |
                  9. | 1004 31-Aug-03 2003 1 -.002951 2003q1 9 .02458093 |
                  10. | 1004 30-Nov-03 2003 2 .001375 2003q2 10 .02352916 |
                  11. | 1004 29-Feb-04 2003 3 .00279 2003q3 11 .0226626 |
                  12. | 1004 31-May-04 2003 4 .003626 2003q4 12 .02191403 |
                  13. | 1004 31-Aug-04 2004 1 .003269 2004q1 13 .02121112 |
                  14. | 1004 30-Nov-04 2004 2 .006807 2004q2 14 .02071512 |
                  15. | 1004 28-Feb-05 2004 3 .003668 2004q3 15 .02012049 |
                  16. | 1004 31-May-05 2004 4 .00783 2004q4 16 .0197199 |
                  17. | 1004 31-Aug-05 2005 1 .006938 2005q1 16 .01989408 |
                  18. | 1004 30-Nov-05 2005 2 .00986 2005q2 16 .0056534 |
                  19. | 1004 28-Feb-06 2005 3 .009732 2005q3 16 .00590139 |
                  20. | 1004 31-May-06 2005 4 .013178 2005q4 16 .00631223 |
                  21. | 1004 31-Aug-06 2006 1 .012039 2006q1 16 .00611721 |
                  22. | 1004 30-Nov-06 2006 2 .013754 2006q2 16 .0063928 |
                  23. | 1004 28-Feb-07 2006 3 .015097 2006q3 16 .00674418 |
                  24. | 1004 31-May-07 2006 4 .016716 2006q4 16 .00554812 |
                  25. | 1004 31-Aug-07 2007 1 .01407 2007q1 16 .00496402 |
                  26. | 1004 30-Nov-07 2007 2 .0157 2007q2 16 .00482606 |
                  27. | 1004 29-Feb-08 2007 3 .01507 2007q3 16 .00462757 |
                  28. | 1004 31-May-08 2007 4 .016183 2007q4 16 .00445286 |
                  29. | 1004 31-Aug-08 2008 1 .011086 2008q1 16 .00391594 |
                  30. | 1004 30-Nov-08 2008 2 .00753 2008q2 16 .00385901 |
                  31. | 1004 28-Feb-09 2008 3 .012301 2008q3 16 .00319603 |
                  32. | 1004 31-May-09 2008 4 .010291 2008q4 16 .00301998 |
                  +------------------------------------------------------------------------------+
                  Hi Nick,

                  I tried to upload the .dta file. But it doesn't work, so I uploaded the excel file. Sorry for this. I will pay attention to this and I will upload the data in a proper in the future.

                  And thanks for your suggestions. I will study it carefully.

                  Shuhui

                  Comment


                  • #10
                    Originally posted by Attaullah Shah View Post
                    Here is an asrol solution. asrol can be downloaded from ssc
                    Code:
                    ssc install asrol
                    
                    import excel "C:\temp\ROA sample.xlsx", sheet("Sheet1") firstrow
                    
                    gen qofd = yq( fyearq , fqtr )
                    
                    format qofd %tq
                    
                    bys gvkey: asrol ROA, stat(sd) window(qofd 16)
                    
                    list gvkey ROA qofd sd16_ROA in 1/20
                    
                    +----------------------------------------+
                    | gvkey ROA qofd sd16_ROA |
                    |----------------------------------------|
                    1. | 1004 .0006407 2001q1 . |
                    2. | 1004 -.0762859 2001q2 .05439532 |
                    3. | 1004 -.0033156 2001q3 .0433167 |
                    4. | 1004 -.0037328 2001q4 .03712734 |
                    5. | 1004 -.0067488 2002q1 .0327507 |
                    |----------------------------------------|
                    6. | 1004 -.000911 2002q2 .03010192 |
                    7. | 1004 .0009004 2002q3 .02813344 |
                    8. | 1004 -.0109507 2002q4 .02605453 |
                    9. | 1004 -.0029512 2003q1 .02458093 |
                    10. | 1004 .001375 2003q2 .02352916 |
                    |----------------------------------------|
                    11. | 1004 .0027897 2003q3 .0226626 |
                    12. | 1004 .0036262 2003q4 .02191403 |
                    13. | 1004 .003269 2004q1 .02121112 |
                    14. | 1004 .0068066 2004q2 .02071512 |
                    15. | 1004 .003668 2004q3 .02012049 |
                    |----------------------------------------|
                    16. | 1004 .0078295 2004q4 .0197199 |
                    17. | 1004 .0069383 2005q1 .01989408 |
                    18. | 1004 .00986 2005q2 .0056534 |
                    19. | 1004 .0097319 2005q3 .00590139 |
                    20. | 1004 .0131781 2005q4 .00631223 |
                    +----------------------------------------+
                    Please note that asrol is blinking fast compared to the rolling command and performance difference is huge in big data sets.
                    Hi Attaullah,

                    Yes my dataset is quite large. Appreciate for your suggestion.

                    Shuhui

                    Comment


                    • #11
                      You don't or shouldn't upload data files in any shape or form. You should copy and paste from Stata into the forum software. The link given in #4 explains this.

                      Also, there is really no need to copy and paste the entirety of someone else's post. Just please refer to it by number.

                      Comment


                      • #12
                        Originally posted by Nick Cox View Post
                        See below for how to give us data, with dataex.

                        Variations on a theme... Yet another way to do it, here with rangestat (SSC).

                        Some points of wider interest:

                        1. For windows ideally of length #, it can be interesting and useful to keep track of the number of values used.

                        2. There is some flexibility over specification of windows. Here it's the present value and (at most) the previous 15, but that is just an example.

                        Code:
                        * Example generated by -dataex-. To install: ssc install dataex
                        clear
                        input int gvkey str9 datadate int fyearq byte fqtr float roa
                        1004 "31-Aug-01" 2001 1 .0006407
                        1004 "30-Nov-01" 2001 2 -.0762859
                        1004 "28-Feb-02" 2001 3 -.0033156
                        1004 "31-May-02" 2001 4 -.0037328
                        1004 "31-Aug-02" 2002 1 -.0067488
                        1004 "30-Nov-02" 2002 2 -.000911
                        1004 "28-Feb-03" 2002 3 .0009004
                        1004 "31-May-03" 2002 4 -.0109507
                        1004 "31-Aug-03" 2003 1 -.0029512
                        1004 "30-Nov-03" 2003 2 .001375
                        1004 "29-Feb-04" 2003 3 .0027897
                        1004 "31-May-04" 2003 4 .0036262
                        1004 "31-Aug-04" 2004 1 .003269
                        1004 "30-Nov-04" 2004 2 .0068066
                        1004 "28-Feb-05" 2004 3 .003668
                        1004 "31-May-05" 2004 4 .0078295
                        1004 "31-Aug-05" 2005 1 .0069383
                        1004 "30-Nov-05" 2005 2 .00986
                        1004 "28-Feb-06" 2005 3 .0097319
                        1004 "31-May-06" 2005 4 .0131781
                        1004 "31-Aug-06" 2006 1 .0120392
                        1004 "30-Nov-06" 2006 2 .0137538
                        1004 "28-Feb-07" 2006 3 .0150972
                        1004 "31-May-07" 2006 4 .0167164
                        1004 "31-Aug-07" 2007 1 .01407
                        1004 "30-Nov-07" 2007 2 .0156996
                        1004 "29-Feb-08" 2007 3 .0150699
                        1004 "31-May-08" 2007 4 .0161827
                        1004 "31-Aug-08" 2008 1 .0110863
                        1004 "30-Nov-08" 2008 2 .0075303
                        1004 "28-Feb-09" 2008 3 .0123014
                        1004 "31-May-09" 2008 4 .010291
                        end
                        
                        gen qdate = yq(fyearq, fqtr)
                        format %tq qdate
                        
                        rangestat (count) roa (sd) roa, int(qdate -15 0) by(gvkey)
                        
                        list, sep(0)
                        
                        +------------------------------------------------------------------------------+
                        | gvkey datadate fyearq fqtr roa qdate roa_co~t roa_sd |
                        |------------------------------------------------------------------------------|
                        1. | 1004 31-Aug-01 2001 1 .000641 2001q1 1 . |
                        2. | 1004 30-Nov-01 2001 2 -.076286 2001q2 2 .05439532 |
                        3. | 1004 28-Feb-02 2001 3 -.003316 2001q3 3 .0433167 |
                        4. | 1004 31-May-02 2001 4 -.003733 2001q4 4 .03712734 |
                        5. | 1004 31-Aug-02 2002 1 -.006749 2002q1 5 .0327507 |
                        6. | 1004 30-Nov-02 2002 2 -.000911 2002q2 6 .03010192 |
                        7. | 1004 28-Feb-03 2002 3 .0009 2002q3 7 .02813344 |
                        8. | 1004 31-May-03 2002 4 -.010951 2002q4 8 .02605452 |
                        9. | 1004 31-Aug-03 2003 1 -.002951 2003q1 9 .02458093 |
                        10. | 1004 30-Nov-03 2003 2 .001375 2003q2 10 .02352916 |
                        11. | 1004 29-Feb-04 2003 3 .00279 2003q3 11 .0226626 |
                        12. | 1004 31-May-04 2003 4 .003626 2003q4 12 .02191403 |
                        13. | 1004 31-Aug-04 2004 1 .003269 2004q1 13 .02121112 |
                        14. | 1004 30-Nov-04 2004 2 .006807 2004q2 14 .02071512 |
                        15. | 1004 28-Feb-05 2004 3 .003668 2004q3 15 .02012049 |
                        16. | 1004 31-May-05 2004 4 .00783 2004q4 16 .0197199 |
                        17. | 1004 31-Aug-05 2005 1 .006938 2005q1 16 .01989408 |
                        18. | 1004 30-Nov-05 2005 2 .00986 2005q2 16 .0056534 |
                        19. | 1004 28-Feb-06 2005 3 .009732 2005q3 16 .00590139 |
                        20. | 1004 31-May-06 2005 4 .013178 2005q4 16 .00631223 |
                        21. | 1004 31-Aug-06 2006 1 .012039 2006q1 16 .00611721 |
                        22. | 1004 30-Nov-06 2006 2 .013754 2006q2 16 .0063928 |
                        23. | 1004 28-Feb-07 2006 3 .015097 2006q3 16 .00674418 |
                        24. | 1004 31-May-07 2006 4 .016716 2006q4 16 .00554812 |
                        25. | 1004 31-Aug-07 2007 1 .01407 2007q1 16 .00496402 |
                        26. | 1004 30-Nov-07 2007 2 .0157 2007q2 16 .00482606 |
                        27. | 1004 29-Feb-08 2007 3 .01507 2007q3 16 .00462757 |
                        28. | 1004 31-May-08 2007 4 .016183 2007q4 16 .00445286 |
                        29. | 1004 31-Aug-08 2008 1 .011086 2008q1 16 .00391594 |
                        30. | 1004 30-Nov-08 2008 2 .00753 2008q2 16 .00385901 |
                        31. | 1004 28-Feb-09 2008 3 .012301 2008q3 16 .00319603 |
                        32. | 1004 31-May-09 2008 4 .010291 2008q4 16 .00301998 |
                        +------------------------------------------------------------------------------+
                        Hi Nick,

                        It is very helpful to keep track of the number of values used, since I require the data from at least eight of the 16 quarters are available. In this case, only focusing when the count is equal and larger than 8.
                        And as for the flexibility of the window, it is easy to change in this command.
                        Thanks!!!

                        Comment


                        • #13
                          If you need to get results only when a given number of observations are available, you can use the option min of asrol
                          Code:
                           
                           bys gvkey: asrol ROA, stat(sd) window(qofd 16) min(8)
                          Also, asrol can generate multiple statistics in one go
                          Code:
                          bys gvkey: asrol ROA, stat(sd count) window(qofd 16) min(8)
                          Regards
                          --------------------------------------------------
                          Attaullah Shah, PhD.
                          Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                          FinTechProfessor.com
                          https://asdocx.com
                          Check out my asdoc program, which sends outputs to MS Word.
                          For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                          Comment

                          Working...
                          X