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
How to read the suest command resultsHi everyone, kindly I have a doubt about reading the results of suest command. I mean after running …
Constraining within covariance to zero in xtheckmanHi, I wanted to estimate a random effects Heckman sample selection model in which I constrain the le…
Estout: saving results with panel dataHi all, I'm running a regression on panel data, where I want the regression to be run separately on…
How to read the suest command resultsHi everyone, kindly I have a doubt about reading the results of suest command. I mean after running …
ivhettest after ivreg2h: last estimates not foundDear Statalist community, I run -ivreg2h- command from SSC with the fe option to implement the esti…
Subscribe to:
Post Comments (Atom)
0 Response to -mkcons- .ado to make a constant
Post a Comment