Hi Stata community.
I am relatively new to Stata. I am doing a project and looking at individuals with random ages. I have to constantly list these numbers whenever I run a new command. I am trying to use a local macro but I have never used it before. If someone could help, I would appreciate it. Below is an example with comments.
I am relatively new to Stata. I am doing a project and looking at individuals with random ages. I have to constantly list these numbers whenever I run a new command. I am trying to use a local macro but I have never used it before. If someone could help, I would appreciate it. Below is an example with comments.
Code:
clear all *Call in sample data sysuse nlsw88.dta *Count if someone is either 34, 37, 41, 45, or 46 count if inlist(age, 34, 37, 41, 45, 46) *Count if someone is either 34, 37, 41, 45, or 46 and race is 2 count if inlist(age, 34, 37, 41, 45, 46) & race==2 *Count if someone is either 34, 37, 41, 45, or 46 and south is 1 count if inlist(age, 34, 37, 41, 45, 46) & south==1 *Attempt to create a local macro local x 34 37 41 45 46 *Ideally, I don't want to use the local macro called x to avoid typing out the numbers 34, 37, 41, 45, or 46 over and over again. *The lines below don't work. count if inlist(age, x) count if inlist(age, x) & race==2 count if inlist(age, 34, x) & south==1
Comment