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 T-Test means of the same variables at different points in time?Hello, I am looking to perform a t-test of the means of different variables between 2013-2014 and 2…
estimating lagged standard deviation of past three yearsI have a panel data setting. I want to create another variable i.e. the standard deviation of invest…
Panel data format: varlist as IDsHello Statalisters, I have the following daily data shape: date day city_1_price_A ... city_70_pric…
Trouble with date functionHey, this is my first post in here, I hope I can master this software and later on help others. So r…
FmmHi, I have an FMM model with three class. Because the dv is binary, logistic regression is used. Le…
Subscribe to:
Post Comments (Atom)
0 Response to -mkcons- .ado to make a constant
Post a Comment