Announcement

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

  • Usage of /// in stata 14.1

    Dear All,

    I am currently trying to learn multilevel modeling. One of the exercises that I have been doing requires me to use /// for seperating commands. However, when I use this in Stata 14.1, it does not work and gives me an 198 error that / is not valid.

    Could anyone tell me how I can solve this problem?

    Many thanks in advance.

  • #2
    From http://www.stata.com/manuals14/perror.pdf, the description about error 198: "All items in this list indicate invalid syntax. These errors are often, but not always, due to typographical errors. Stata attempts to provide you with as much information as it can. Review the syntax diagram for the designated command."

    Comment


    • #3
      Please provide stata output in [CODE] delimiters

      Comment


      • #4
        thank you for your response Aaditya

        I checked but the manual does not provide an answer to my problem. According to the study guide I am using it says: "where we have used the /// line join indicator to inform Stata that the two lines of code form one command. If we did not do this, Stata would incorrectly
        interpret the second line as a new command."


        The code is:

        . bysort schoolid (cohort90): replace multiplecohort = 0 /// if cohort90[_N]==cohort90[1]
        / invalid name
        r(198);


        After checking a couple of times and making sure I typed in the correct command (I even copied and pasted it a couple of times) it still says that / is invalid. That's why I thought, maybe stata 14.1 does not allow the /// and uses a different indicator instead when compared to previous versions

        Do you know this by any chance?
        Last edited by Timon Graaff; 21 May 2016, 00:36.

        Comment


        • #5
          The /// comments dont work using the command window. Your command seems correct, but must be run from a do file.
          Last edited by Bjarte Aagnes; 21 May 2016, 02:34.

          Comment


          • #6
            To summarize, the sequence "///" is used within do-files and within the do-file editor window to indicate that a command is to be continued on the following line. If you type a command directly into the command window, you can type as long a command as you want, it will wrap to fit the window, so "line continuation" is not supported because it is, technically, not needed, although it would be nice if it worked, to make copy-and-paste easier sometimes.

            So in a do-file or in the do-file editor window, your command would be, if typed on two lines
            Code:
            bysort schoolid (cohort90): replace multiplecohort = 0 ///
            if cohort90[_N]==cohort90[1]
            While in the command window your command would be on a single line
            Code:
            bysort schoolid (cohort90): replace multiplecohort = 0 if cohort90[_N]==cohort90[1]
            You could also type your command on a single line in a do-file or in the do-file editor window.

            Comment


            • #7
              Thank you all! My problems is solved

              Comment


              • #8
                Just to add that /// is allowed in programs too, not just do-files.

                Comment


                • #9
                  Nick is correct, in discussing do-files and the do-file editor, I overlooked ado-files, the common home of programs, where /// is also allowed as a continuation. But if you type a program into the command window, no luck.

                  Comment


                  • #10
                    For long multiline commands, I favor switching to a semicolon delimiter:
                    Code:
                    #delim ;
                    long multiline command(s) each ending in ;
                    #delim cr
                    Otherwise I have to line up the ///s on the right for the command to look neat, and I find that more trouble than it is worth. The semicolon also makes it possible to put several very short commands on one line.
                    Last edited by Steve Samuels; 26 May 2016, 12:34.
                    Steve Samuels
                    Statistical Consulting
                    [email protected]

                    Stata 14.2

                    Comment


                    • #11
                      For readers new to #delim let me point out that #delim—like ///—is not understood within the command window.

                      Comment


                      • #12
                        Some common mistakes with both (well, common for me anyway) -- with ///, remember to put a space before the ///. Otherwise what often happens is that two options get run together and you get a syntax error, e.g. if you specify

                        opt1///
                        opt2

                        Stata reads it as opt1opt2 and generates an often inexplicable error message.

                        For delim, I sometimes forget the closing ; then my commands get run together and I get more weird errors.

                        Personally, I like the visual aesthetics of /// -- plus you can see quickly that the command isn't finished yet -- but delimit is less work.
                        -------------------------------------------
                        Richard Williams, Notre Dame Dept of Sociology
                        StataNow Version: 19.5 MP (2 processor)

                        EMAIL: [email protected]
                        WWW: https://www3.nd.edu/~rwilliam

                        Comment

                        Working...
                        X