Announcement

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

  • Display command

    Hello,

    I've written a display command to my do file, such as:
    di "whatever, does not matter"

    When I execute it, on the main screen I can see both, the command and the output, which was expected. However, I would like the main screen to display ONLY the output. Is there any way to hide the command on the main screen?

    Thank you.

  • #2
    As far as I know, it is not possible to generate output without also echoing the command in Stata. The closest you can come is to wrap the -display- command inside a program and then call the program. But then the call to the program will be echoed to the Results window.

    I'm curious why you want this. It seems like a really bad idea to show output with no indication of what it is the output of. When you come back to it later, how will you or anybody else know what it means?

    Comment


    • #3
      Ah, I understand. Just purely for aesthetics, since in the command, I have rather long strings of text that explain the value shown [such as: di "Whatever, whatever..... with minimum " r(min)], and seeing the text twice on the Results window (once in command, once in output) doesn't look particularly nice. Thank you for your answer either way.

      Comment


      • #4
        I'm a little confused - if I set up a do file and put noisily in front of, say, a display command, then I get the result but not the command when I "run" (rather than "do"the file) - am I misunderstanding what is being asked?

        Comment


        • #5
          Ah, Rich Goldstein is right. I almost never use -run-, so I forgot about it. But yes, -run- runs the do-file as if the whole thing were being run -quietly-. But a -noisily- within that will break through.

          Comment


          • #6
            When I have a do-file where I want just a subset of commands to display their output, without the commands themselves being interspersed, I use the following approach, which exploits the way foreach loops are handled by Stata. Often I'm annoyed that commands within foreach loops are not repeatedly echoed, but I can turn that flaw into a feature in this case.
            Code:
            . do "/var/folders/xr/lm5ccr996k7dspxs35yqzyt80000gp/T//SD15526.000000"
            
            . foreach dummy in dummy {
              2. display
              3. display "Once upon a midnight dreary"
              4. display "While I pondered weak and weary"
              5. }
            
            Once upon a midnight dreary
            While I pondered weak and weary
            
            .
            end of do-file

            Comment

            Working...
            X