Hey,
For my dataset I have 20+ years of data with 19 unique countries per year
I want to create 1 column where every country gets its own dummy number, without typing everything out like so:
generate countrydummy = 0
replace countrydummy =1 if Country == " Austria"
replace countrydummy =2 if Country == "Belgium"
etc..
Is there a way to efficiently create a dummy for every country? (I do not want to use: tabulate Country, generate(countrydummy) because I will get 19 columns.. )
Related Posts with Creating dummy for unique value
Mismathing data when summarizing a variableWhen I try to summarize data the information that the functio returns to me doesn't match with what …
Change last 4 digits in String type How can I change last 4 digits of co_end_variable to finyear ? For the data below, for example, 01…
How can I multiply two category variables by another category variable to create a new variable? Hi All, I want to create a new variable which is (Age * Education levels). But the problem is that…
How to create a variable representing the max length of consecutively same numbers in a row?I am trying to find a way to caculate the max length of consectively same numbers in each row . For …
In a loop, strtrim() won't work in some of my variablesHello everyone! I'm facing a little difficulty using the strtrim() command here. As always, I looked…
Subscribe to:
Post Comments (Atom)
0 Response to Creating dummy for unique value
Post a Comment