0 of 7 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 7 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)
First Stata stores “10/5” in the local macro “num”. Stata does not execute the calculation because I did not include “=” when defining the macro; i.e. I typed “local num 10/5” not “local num = 10/5”. For the display command, Stata replaces the macro with the value “display 10/5”. Since “display” acts like a calculator when it’s given a numeric function, then Stata executes the calculation, and returns “2”.
First Stata stores “10/5” in the local macro “num”. Stata does not execute the calculation because I did not include “=” when defining the macro; i.e. I typed “local num 10/5” not “local num = 10/5”. For the display command, Stata replaces the macro with the value “display “10/5″”. Since there are quotation marks around “10/5”, Stata treats it like a string and returns exactly what is in the quotation marks without attempting any calculation, i.e. “10/5”.
Since I include “=” when I defined the local macro, Stata attempts to execute the calculation. Since 10/5 = 2, Stata saves the number 2 in the local macro num. Then when I display the value of this local macro, Stata returns 2. (Note that since I display num in quotation marks, Stata is treating “2” like a string rather than a number. If I had wanted to do any calculations with “`num’”, then I would have had to remove the quotation marks from `num’ in the display command).
Stata stores the results of calculations in internal macros that follow the “r([macro])” naming convention. For some estimation commands (like regress), Stata stores results in “e([macro])”. You can view the stored macros after a command by typing “return list”. If you run a summarize command and then type “return list”, you’ll see that Stata stored the standard deviation value in the local macro “r(sd)”.
Stata stores the results of calculations in internal macros that follow the “r([macro])” naming convention. For some estimation commands (like regress), Stata stores results in “e([macro])”. You can view the stored macros after a command by typing “return list”. If you run a t-test command and then type “return list”, you’ll see that Stata stored the p-value from a two-sided test in the local macro “r(p)”.
To view the answer, run the following commands on the EG DIB baseline dataset: sum hindi_bl, det disp `r(p99)’
or you can type “return list” in the command line after running the summarize command.
Hardcoding refers to manually entering values from previous calculations or functions rather than saving and using them programmatically. This can lead to copy-paste errors, errors from rounding (e.g. if Stata only displayed the first 10 significant digits, but the actual value has more significant digits), and may be inefficient in long code or code that you update and run multiple times.
1. Suppose that I create a macro in my .do file with the command “local num 10/5” and follow it with the command “display `num’”. What would be displayed?
2. Suppose that I create a macro in my .do file with the command “local num 10/5” and follow it with the command “ display “`num’” ”. What would be displayed?
3. Suppose that I create a macro in my .do file with the command “local num = 10/5” and follow it with the command “ display “`num’” ”. What would be displayed?
4. What is the name of the internal macro for standard deviation that is created after the summarize command?
5. What is the name of the internal macro for p-value that is created after the t-test command?
6. Load the EG DIB dataset and summarize hindi_bl with the ‘detail’ option. What value is stored in r(p99)?
7. Why is hardcoding bad? (Choose all that apply)
27 November 2024
18 November 2024
13 November 2024
11 November 2024
5 November 2024
25 October 2024
22 October 2024
21 October 2024
12 September 2022
Username or Email Address
Password
Remember Me