Temporary Names, Variables and Files
Rafael Gafoor · 2024
Sometimes we want to create a temporary variable to store some information that we will use later in the program we are writing. Sometimes, we may want to keep this variable for quite a while. We may create the variable at the beginning of the analysis but not use it until the end. In some cases, we may create a temporary variable and use the contents almost immediately (or at least within the same program that created it). One significant issue that arises is that, in creating a variable, we might accidentally overwrite another variable with the same name. For this reason, it is good programming practice to create temporary variables with temporary names. If you keep track of these and delete them as soon as necessary, then it is less likely that you will cause errors in your analysis. Stata allows you to create three types of temporary entities – namely temporary variables, names and files. Temporary variables and names are deleted at the end of the program (environment) in which they were created, so you don’t have to keep track of them once the program you have created them in has ended.