I have a variable for U.S. states that includes 01, 02, 03, ... , 50, 51, and these are all strings representing the 50 U.S. states and the District of Columbia. I would like to regress a dependent variable on each state individually as a dummy binary variable, but I don't want to have to create 51 separate dummies.
Is there a quick way to do this? I'm aware of using "i" to create separate dummies (e.g. "reg depvar i.indepvar"), but this doesn't seem to work since the "states" variable contains strings.
Any help is appreciated.
Related Posts with Convert Single String Variable to Many Binary Variables
Using hyphens in varlists for duplicatesI'm using Stata 14.2 and was trying to use the duplicates command, when I experienced some strange b…
Duplicating time observations in panel data in stataHello Stata community, I am looking to duplicate the time observations in a panel data 17 times, wh…
Exporting Variables to ExcelHi! I have created a few variables that I'd like to export to an excel file. I have variables rf1 th…
Levels of variables "dropped because of estimability" when running a nested regressionWhen I run a nested regression, I'm getting the following notes: note: 1.deprivationquintile dropped…
Stata doesn't read local macroHi, I am trying to use macros to avoid repeating long lists of variables. The problem is that Stata …
Subscribe to:
Post Comments (Atom)
0 Response to Convert Single String Variable to Many Binary Variables
Post a Comment