Announcement

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

  • display command in Stata

    Hi,

    I am reading a Stata script which contains the following code:

    Code:
    di in ye "Year `year'"
    I know di stands for display. But I am not sure what display is trying to do here. Any help will be highly appreciated.

  • #2
    Just try it and you will see what it does:

    Code:
    . local year = "bla bla bla"
    
    . di in ye "Year `year'"
    Year bla bla bla

    Comment


    • #3
      Joro Kolev Thank you. Got it!
      Last edited by Taz Raihan; 26 Mar 2021, 19:19.

      Comment


      • #4
        Ah, but to me, the interesting question is what was to be accomplished in
        Code:
        di in ye "Year `year'"
        by the two tokens highlighted in red?

        The only "in" supported (in Stata 16.1) is "in smcl". And while "ye" can be a variable name, or an abbreviated variable name, "in" is not a permitted variable name and even if it is an abbreviation, attempting to use it in this context causes an error.
        Code:
        . list, clean noobs
        
             income       yellow  
            inc ...   yellow ...  
        
        . di income yellow "foo"
        inc ...yellow ...foo
        
        . di i y "foo"
        inc ...yellow ...foo
        
        . di i ye "foo"
        inc ...yellow ...foo
        
        . di in ye "foo"
        foo
        
        .

        Comment


        • #5
          my memory says that many versions ago, one could call for a specific color within one's -display- command and my guess is that this is a very old "script"; and one can still do this though it does not appear to be documented; is there, by any chance, a "version #" statement in there?

          Comment


          • #6
            Ah, yes, if I substitute "in re" (or "in r" or "in red") for "in ye" I get output in red. Even spelling out "yellow" doesn't do the trick, however: the results remain black. I'm guessing the syntax is still parsed but perhaps fewer colors are supported.

            Comment


            • #7
              William, as Rich said, this is an (undocumented?) directive for colour.

              I believe the directive "in yellow" still works, but you are not seeing it because your Stata is in this view where you have black letters on white background. In this black letters on white background you see the directive "in red" fine.

              If your Stata is in this "the terminal" view, black background and bright green letters, I believe you will see the directive "in yellow" just fine.


              Originally posted by William Lisowski View Post
              Ah, yes, if I substitute "in re" (or "in r" or "in red") for "in ye" I get output in red. Even spelling out "yellow" doesn't do the trick, however: the results remain black. I'm guessing the syntax is still parsed but perhaps fewer colors are supported.

              Comment


              • #8
                Here is how the "in colour" directives look on Stata 15.1 when Stata is in Classic view.
                Attached Files

                Comment


                • #9
                  See also

                  Code:
                  help _tab
                  which counts as a undocumented command.

                  Note to the bemused: undocumented Stata sense means "documented in the online help but not in the manuals". It doesn't mean not documented. Not documented commands can still be known about because


                  1. As here, someone remembers older stuff no longer documented.

                  2. You find them used in code and it's evident, or someone explains, what it does.

                  Comment


                  • #10
                    to give a little more - colors were, IIRC, used originally because there was only one background color; however, for many years now, people can choose their background color and StataCorp responded by changing from colors to the "as" option where the color of, e.g., "text", depends on the background color; for more see [P] display (pdf)

                    Comment

                    Working...
                    X