How can I easily create dummy variables for a given Field?
For example, let's say a Field Category has the unique values of x,y and z. I want to create dummy_x, dummy_y and dummy_z with values of 1 or 0 based on the Category field. Now, I have more than 3 unique values and it is difficult to create the dummy variables one by one.
Is there a way to dynamically create the dummy variables based on the values of a particular field?
Solved! Go to Solution.
Yes you can create dummy for each.
The easiest way I can think of is to use a transpose to put all the fields you want to create as rows.
You can then use a formula tool to make a dummy column name.
Then use a cross tab to make it column based.
After this you can use a MultiField formula tool to fill in the nulls.
Sample attached
Thanks, that worked well.
CrossTab with the boolean Field added is what I was looking for.
Hi, please could you share what the workflow looks like for the crosstab + boolean field you mentioned?
Ignore, it is in jdunkerley79's sample workbook.
Thank you for your solution
Please also try our new macros from CReW
https://gallery.alteryx.com/#!app/CReW-Generate-Dummy-Variables/5fca958e0462d71998cd0aac
User | Count |
---|---|
19 | |
15 | |
13 | |
9 | |
8 |