Hello,
I have some script that I need to be able to re-run many times. The script creates some variables as it goes. I don't want to manually delete these variables before I run the script. I thought I could use capture drop - however there appears to be an issue:
I have two variables: age and agesex. I want to drop agesex at the beginning of the script. However, if agesex is not present in the data (the data might be refreshed so the variables created in the script, have not been created) the variable age is dropped. I am guessing this is because Stata thinks that age is an abbreviation of agesex.
Has anyone come across this before, and if so does anyone know how to go about addressing this issues in the code.
Ideally, I want something like "if exists" that you can use in SQL.
I have some script that I need to be able to re-run many times. The script creates some variables as it goes. I don't want to manually delete these variables before I run the script. I thought I could use capture drop - however there appears to be an issue:
I have two variables: age and agesex. I want to drop agesex at the beginning of the script. However, if agesex is not present in the data (the data might be refreshed so the variables created in the script, have not been created) the variable age is dropped. I am guessing this is because Stata thinks that age is an abbreviation of agesex.
Has anyone come across this before, and if so does anyone know how to go about addressing this issues in the code.
Ideally, I want something like "if exists" that you can use in SQL.
Comment