Announcement

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

  • Opening hyperlink to file unsuccessful with esttab

    I'm using Stata 15.1 on MacOS Mohave.

    After running:

    Code:
    esttab ped*aafs cyc*aafs using "tables/Logit Estimation Results, All Speed Zones, 2000-2017.doc" ,  ///
    rtf noomitted nobaselevels eform nogaps nonumbers legend collabels(none) ///
    eqlabels(none) onecell b(3) p(2) pr2(3) obslast label replace ///
    mlabels("Pedestrian Slight" "Pedestrian Severe/Fatal" "Cyclist Slight" "Cyclist Severe/Fatal") ///
    indicate("Weather Groups = *weather" "Season Groups = *season" "Year Dummies = *year") ///
    addnotes("Standard errors clustered at accident level" ) ///
    title("Logistic Regression Estimation Results by Injury Group, All Speed Zones, 2000-2017") ///
    varwidth(22) modelwidth(9)
    I get a nifty link to the exported file in the results window that looks like:

    Code:
    (output written to tables/Logit Estimation Results, All Speed Zones, 2000-2017.doc)
    However, when I click on the link in the results window it opens up Safari and all I see is a blank white page. If I find the file in Finder I can open it without any issues. Moreover, if I type
    Code:
     shell open "tables/Logit Estimation Results, All Speed Zones, 2000-2017.doc"
    the file opens in the default application as expected.

    I'm looking for some general advice on what might be going wrong, and how to fix the issue. I might also add that there is not some event that I can point to as a possible suspect for causing the issue because I don't ever remember not having the issue.

  • #2
    This has proven a fascinating exercise (if you're easily fascinated by arcana).

    I am running the same Stata setup as you. When I used estout to create a link and then clicked on it, the file opened in Word as I expected. It turns out I shouldn't have expected that.

    The approach taken by estout is to write to your Results window the SMCL tag
    Code:
    {browse  "tables/Logit Estimation Results, All Speed Zones, 2000-2017.doc"}
    to display the clickable file name. Now the problem is that help smcl tells us that

    {browse} displays text as a link that will launch the user's browser pointing at args
    So I tried again, but this time I included a space in the filename, as you have. Because the SMCL browse directive expects a URL, it encodes spaces as %2520 (look in Safari's Address and Search box when it fails to load). And Safari, even though it recognizes that it's been given a filename rather than an http/https URL, apparently doesn't decode %2520 back to a space when it tries to locate and open the file.

    So overall I'd say that using the SMCL browse directive to create a clickable link to open a file, rather than a URL, is ... not guaranteed to work. Your browser may vary; Windows users are invited to try this and report the results. The basic test is
    Code:
    clear
    eststo clear
    sysuse auto
    eststo: quietly regress price weight mpg
    eststo: quietly regress price weight mpg foreign
    esttab using "foo bar.doc", ar2 rtf replace
    after which when using macOS and Safari clicking the link in the log hangs in Safari, but removing the space between foo and bar results in the file opening.





    Comment


    • #3
      Thank you! After removing spaces from the filename, the hyperlink works.

      Comment

      Working...
      X