I would like to give Stata the command to find a word inside a .do file.
I know I could use Ctrl+F, but I would like to do it with an inline command.
Is there such a command?
This is the reason for doing it.
I have a very large dataset, with many variables, that I would like to share with someone; with this person, I will share also the .do file that I use to conduct analyses on this dataset.
To make the .dta file lighter, I would like to drop from this .dta all of the variables that I do not use in the .do file.
So, my idea is to write a command (which loops over all the variables in the dataset) that would look for words (i.e. the names of the variables) into the .do file and, if Stata doesn't find this word, it will drop the corresponding variable.
Any idea on how to do it?
I know I could use Ctrl+F, but I would like to do it with an inline command.
Is there such a command?
This is the reason for doing it.
I have a very large dataset, with many variables, that I would like to share with someone; with this person, I will share also the .do file that I use to conduct analyses on this dataset.
To make the .dta file lighter, I would like to drop from this .dta all of the variables that I do not use in the .do file.
So, my idea is to write a command (which loops over all the variables in the dataset) that would look for words (i.e. the names of the variables) into the .do file and, if Stata doesn't find this word, it will drop the corresponding variable.
Any idea on how to do it?
Comment