Announcement

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

  • Save results of estat ptrends to file

    How can I save the result of `estat ptrends` and `estat granger` to file? I have tried with etable, but it saves a regression table rather than the result of the test.

    If I print it to screen, it would be logged, but I (1) would like to avoid to print it on screen and (2) avoid to log it because it happens that I restart the script with minor modifications and lose the previous log (3) it is inconvinient as everything is logged and I have to retrieve it from a quite long long

  • #2
    The output of
    Code:
    help didregress postestimation
    when you scroll down to the bottom tells you the scalars returned by estat ptrends and estat granger in r().
    Code:
    help return
    With that said, the output of
    Code:
    help log
    tells you how you can control what is captured by a logfile, and how you can use commands to turn the log on and off in your do-file.

    Comment


    • #3
      Hi,

      I have read the help pages you pointed out.

      I knew how to get the names of the returned values.

      But I still don't understand how to save those results in an Excel file.

      Once I write
      Code:
      return scalar pvalue = r(p)
      How do I save that in an Excel file?

      Comment


      • #4
        Perhaps this example will start you in a useful direction.
        Code:
        sysuse auto, clear
        summarize price
        return list
        putexcel set example.xlsx, replace
        putexcel a1="N" b1="Mean"
        putexcel a2=(r(N)) b2=(r(mean))
        putexcel save
        Code:
        . sysuse auto, clear
        (1978 automobile data)
        
        . summarize price
        
            Variable |        Obs        Mean    Std. dev.       Min        Max
        -------------+---------------------------------------------------------
               price |         74    6165.257    2949.496       3291      15906
        
        . return list
        
        scalars:
                          r(N) =  74
                      r(sum_w) =  74
                       r(mean) =  6165.256756756757
                        r(Var) =  8699525.974268788
                         r(sd) =  2949.495884768919
                        r(min) =  3291
                        r(max) =  15906
                        r(sum) =  456229
        
        . putexcel set example.xlsx, replace
        Note: File will be replaced when the first putexcel command is issued.
        
        . putexcel a1="N" b1="Mean"
        file example.xlsx saved
        
        . putexcel a2=(r(N)) b2=(r(mean))
        file example.xlsx saved
        
        . putexcel save
        
        .
        Click image for larger version

Name:	excel.png
Views:	1
Size:	26.2 KB
ID:	1664565

        Comment


        • #5
          Thanks!

          Comment

          Working...
          X