Dear data cleaners
I made a small program to check whether there is a constant called cons in the data set, and if not, to make it and set its value equal to 1. I use it when I don't know what a program is doing. The system variable _cons doesn't seem to work in all applications (e.g. in collapse). I would like to throw it on SSC so that if I share my syntax, people can also download it and proceed. I actually have a couple of such little ado's and perhaps I should group them.
Please vent your opinion if this little ado would be a good practice, or whether it is useless or redundant.
Thanks
Sem
cap program drop mkcons
program define mkcons
capture sum cons
if _rc == 0 {
if (r(min) != r(max)) | (r(mean) !=1) {
replace cons = 1
di as result "Cons is not constant or not equal to 1"
}
else {
di as result "Cons = 1 already exists"
}
}
if _rc != 0 {
gene byte cons = 1
di as result "Cons = 1 has been made"
}
end
mkcons
Related Posts with -mkcons- .ado to make a constant
Stacked bar graph for a binary and a categorical variableHi. I have a binary variable, OC, and a categorical variable Department. Department has 16 categorie…
Announcement of the Stata Journal Editors’ Prize 2023Stata Journal 23(1) released last week carries an invitation to nominate for the Editors' Prize in 2…
Deleting ID that is not present in both datasets for Panel DataHi, I am interested in doing regression analysis with panel data.The data I've chosen is in 2 waves…
Box Cox regression (Lambda model) result shows 0.000 standard errors for estimated coefficients and Sigma constantHello all, I am Florence Ijagbone. I am working on the social welfare function as part of my PhD pr…
EGARCH modelling expressionsHi everyone, I was wondering if anyone would be able to help me with an issue I have come across on…
Subscribe to:
Post Comments (Atom)
0 Response to -mkcons- .ado to make a constant
Post a Comment