Announcement

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

  • which command prevents displaying the stata command in a do file

    while quietly silences everything, is there a command or prefix that allows a stata command not do display itself during the evaluation of a do file, however I do want to see the output of such command when the script runs.

  • #2
    You can use noisily within quietly to display a command's output while suppressing the command itself. For instance:

    Code:
    quietly{
        clear
        set obs 50
        gen x = runiform()
        gen y = runiform()
        noisily reg y x
    }
    Which outputs:

    Code:
    . quietly{
    
          Source |       SS           df       MS      Number of obs   =        50
    -------------+----------------------------------   F(1, 48)        =      0.00
           Model |  .000209382         1  .000209382   Prob > F        =    0.9522
        Residual |  2.76747995        48  .057655832   R-squared       =    0.0001
    -------------+----------------------------------   Adj R-squared   =   -0.0208
           Total |  2.76768933        49  .056483456   Root MSE        =    .24012
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
               x |    .006325   .1049578     0.06   0.952    -.2047068    .2173569
           _cons |   .5235474   .0629634     8.32   0.000      .396951    .6501438
    ------------------------------------------------------------------------------
    
    . 
    end of do-file

    Comment


    • #3
      perfect, I wouldn't have guessed it

      Comment


      • #4
        A slightly different approach that separately displays of the commands and their output. For those like me who need to see their commands in their log files to remember what they were doing,
        Code:
        . foreach dummy in dummy {
          2.     clear
          3.     set obs 50
          4.     gen x = runiform()
          5.     gen y = runiform()
          6.     regress y x
          7. }
        number of observations (_N) was 0, now 50
        
              Source |       SS           df       MS      Number of obs   =        50
        -------------+----------------------------------   F(1, 48)        =      0.15
               Model |  .012955144         1  .012955144   Prob > F        =    0.6982
            Residual |    4.087633        48  .085159021   R-squared       =    0.0032
        -------------+----------------------------------   Adj R-squared   =   -0.0176
               Total |  4.10058815        49  .083685472   Root MSE        =    .29182
        
        ------------------------------------------------------------------------------
                   y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                   x |   .0614949   .1576642     0.39   0.698    -.2555103    .3785001
               _cons |   .4928259   .0786106     6.27   0.000     .3347686    .6508831
        ------------------------------------------------------------------------------
        
        .

        Comment


        • #5
          very helpful, is there a variation around Ali Atia that doesn't display "quietly{"

          Comment


          • #6
            Surprisingly, but just technically, yes, although this may not really be an improvement in what it displays.
            Code:
            set output error
            
            clear
            set obs 50
            gen x = runiform()
            gen y = runiform()
            noisily display "this is my regression"
            noisily reg y x
            predict yhat 
            
            set output proc
            summarize y yhat
            Code:
            . set output error
            this is my regression
            
                  Source |       SS           df       MS      Number of obs   =        50
            -------------+----------------------------------   F(1, 48)        =      2.79
                   Model |  .196257212         1  .196257212   Prob > F        =    0.1013
                Residual |  3.37563214        48   .07032567   R-squared       =    0.0549
            -------------+----------------------------------   Adj R-squared   =    0.0353
                   Total |  3.57188935        49  .072895701   Root MSE        =    .26519
            
            ------------------------------------------------------------------------------
                       y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                       x |   .2263084   .1354705     1.67   0.101    -.0460733    .4986901
                   _cons |   .4355514   .0748425     5.82   0.000     .2850705    .5860323
            ------------------------------------------------------------------------------
            
            . summarize y yhat
            
                Variable |        Obs        Mean    Std. Dev.       Min        Max
            -------------+---------------------------------------------------------
                       y |         50    .5437486     .269992   .0176726   .9904616
                    yhat |         50    .5437486     .063287   .4443536   .6595232
            
            .

            Comment


            • #7
              interesting, this is extremely helpful; sometimes I like to see the concise data.

              Comment


              • #8
                Thank you, Mr Atia, for a great solution for an issue I was looking for!

                Also, any idea if you can create a shortcut for a command I use very frequently like "codebook"

                Comment

                Working...
                X