0 of 4 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 4 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0) 0 Essay(s) Pending (Possible Point(s): 0)
You can specify a comment in Stata by putting “*” at the front of a line. Stata will ignore everything in that line when it executes the .do file. You can also put “//” in front of a line to comment it out. Or you can put “/*” to start a comment and “*/” to end a comment. Everything in between will be ignored by Stata (even if it’s multiple lines). Note that if you forget to put “*/” at the end then Stata will comment out everything in the .do file that follows “/*”.
You need to install user-written commands in order to use them (Stata will not do this automatically for you). If Stata encounters an error while running a .do file, it will run the .do file up to that point and then stop running the .do file and not attempt to execute subsequent commands. You will have to fix the error and rerun the .do file.
A carriage return (i.e. pressing ‘Enter’ on your keyboard to go to the next line) is the default delimiter for Stata; anything on one line will be considered a single command, and going to the next line will be considered a different command. However, you can split a command across multiple lines by putting “///” at the end of a line; this tells Stata to continue reading to the next line before attempting to execute the command. This is useful for typing really long commands, so that you don’t have to scroll endlessly to the right to read the command. For graphing commands, I like to split each option onto a different line.
Another way to split a command across multiple lines is to specify a different delimiter than a carriage return. This avoids the need to put ‘///’ at the end of every line in the command, since you only need to put the delimiter at the end of the last line in the command. A common alternative delimiter is a semicolon. So you would specify this by entering the command:
#delimit ;
Now you can split a command across as many lines as you want. Put a ‘;’ at the end of the command. Of course you will have to put a ‘;’ at the end of every command (including single-line commands), unless you change the delimiter back to a carriage return:
#delimit cr
1. Which of the following lines of code will Stata recognize as a comment? (Choose all that apply)
2. What would happen if you ran a .do file that included a user-written command that you had not already installed on your machine?
3. Which of the following can be used to split a long command across multiple lines? (Choose all that apply)
4. Start a new .do file to save the code for the remainder of lesson. Include an intro and section headers for the following tasks (which you will fill in during this lesson): macros, foreach loops, forvalue loops, and bysort. Did you create a .do file with the suggested elements?
6 December 2024
5 December 2024
4 December 2024
3 December 2024
12 September 2022
Username or Email Address
Password
Remember Me