Announcement

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

  • Writing double quotes to a file

    I am struglling with writing double quotes to a file, see the following example
    Code:
    cap file close myfile
    file open myfile using address.do, write replace
    file write myfile "global root `" " " '  `c(pwd)'"  _n
    cap file close myfile
    However, it returns the error
    Code:
    invalid syntax
    . I have also tried `=char(34)' instead of `" " "', or " " " but to no avail. Your comments are appreicated.
    Last edited by Attaullah Shah; 03 Oct 2015, 05:15.
    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.

  • #2
    This seems to work:
    Code:
    display `"global root "`c(pwd)'" "'

    Comment


    • #3
      Thanks Svend, it worked. I had found a different solution, that is, to write each double quote on a single line, i.e.
      Code:
      file write myfile "global root"
      file write myfile """ 
      file write myfile `c(pwd)'
      file write myfile """ _n
      however, your approach is far cleaner.
      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