Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Stata reference for writing, debugging, and explaining .do files: econometrics, causal inference, Mata, and community packages.
77% 100%+23 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 17 of 22 without it.
Create a new indicator variable 'high_score' that equals 1 if 'score' is strictly greater than 90, and 0 otherwise. The dataset contains missing values, which must not be flagged as high scores.
Explicitly excludes missing values using !missing(score) or score < .
3 of 3 safety checks passed
You have access to comprehensive Stata reference files. Do not load all files. Read only the 1-3 files relevant to the user's current task using the routing table below.
These are Stata-specific pitfalls that lead to silent bugs. Internalize these before writing any code.
Stata's . (and .a-.z) are greater than all numbers.
* WRONG — includes observations where income is missing!
gen high_income = (income > 50000)
* RIGHT
gen high_income = (income > 50000) if !missing(income)
* WRONG — missing ages appear in this list
list if age > 60
* RIGHT
list if age > 60 & !missing(age)
= vs === is assignment; == is comparison. Mixing them up is a syntax error or silent bug.
* WRONG — syntax error
gen employed = 1 if status = 1
* RIGHT
gen employed = 1 if status == 1
Locals use `name' (backtick + single-quote). Globals use $name or ${name}.
Forgetting the closing quote is the #1 macro bug.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.