Announcement

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

  • breaking a command line into multiple lines in a do-file

    Hi,

    I am using /// to break long lines of Stata commands into multiple lines to improve readability of my do-files. It works in the case of command such as -twoway- (i.e. the /// turns green and breaks the line and the command is run with no problem). But, for a command like -display- it doe snot do what is it supposed to.

    Any suggestion?

    Thanks,
    Navid

  • #2
    Please show exactly what you entered and the resulting error messages. There is no way anyone can help you without this information.
    Richard T. Campbell
    Emeritus Professor of Biostatistics and Sociology
    University of Illinois at Chicago

    Comment


    • #3
      Use /* */ to continue the display line:

      Code:
      disp "Hello "     /*
          */ "World"

      Comment


      • #4
        Code:
        display "Hello " ///
        "world"
        works for me (Stata 13 and 14), but /// is only valid in a do-file, not in the command window. Is that the problem?

        Comment


        • #5
          Splitting long strings (constants) across multiple lines has been already discussed at the forum, see here.

          Comment


          • #6
            You might consider using the "#delim ;" option if you find yourself using long multline commands a lot. For example,
            Code:
            display "hello ///
              world"
            throws an error, but
            Code:
              #delim ;
              
              display "hello 
              world";
            works fine. The /// approach is sensitive to quotation marks, while the #delim ; approach is not.

            Comment


            • #7
              This worked for me

              Code:
              disp "Hello " /* */ "World" Thanks a lot

              Comment


              • #8
                Hi, I've just read these posts and I have the same question but using other command, below i wrote what i want to write:

                keep var12 caseid v138 hw13
                height weight age
                job v016

                Where: var12, caseid, v138, hw13, height, weight, age, job, v016 are variables which i want to keep
                I will appreciate if anyone can help me. Thanks in advance
                Last edited by Brian Yalle; 16 Nov 2015, 16:53.

                Comment


                • #9
                  see "h delimit" and "h comments" - as you will see, there are multiple ways to do this

                  Comment


                  • #10
                    Thanks a lot, in fact, I used:
                    #delimit ;
                    keep caseid sregion v024 v025 v040 v701 v705 s108n s496 v012 v131 v155 v156
                    v157 v158 v501 v714 v717 b9 b16 s720a v013 v190 v150 v151 v152 v208 ;
                    #delimit cr
                    and it works!

                    Comment

                    Working...
                    X