Top "Stata-macros" questions

A macro in Stata is comprised of a name and contents.

Tabulate multiple variables with common prefix using a local macro

I have a number of variables whose name begins with the prefix indoor. What comes after indoor is not numeric (…

loops stata stata-macros
How to rename many variables with string suffixes

In Stata, I have a set of variables that all begin with pkg. In their current state, their endings are …

foreach stata stata-macros
Macros constantly resulting in 'invalid name'

I'm a newcomer to Stata after using R for a long time. I'm trying to perform any action which involves …

stata stata-macros
Drop variables with all missing values

I have 5000 variables and 91,534 observations in my dataset. I want to drop all variables that have all their values missing: …

stata stata-macros
How to store a mean value in a local macro and then save it in another file?

I have a Stata file file1.dta and one of the variables is income. I need to calculate average_income, …

stata local-variables stata-macros