Dear All,
The issue I am trying to resolve here is as follows-
I have a dataset where customers purchase products from multiple brands in a single order, identified by "Order_id". The variable "Brand", has 5 unique values, but in a single order it may be present once or more than once. I want to create new columns with the brand name, which indicates if it was present in a certain order (i.e. takes values of 1/0 in the new column). Please find below an example:
My existing data:
Order_id Brand
100 A
100 B
100 C
101 D
101 D
102 E
102 A
102 C
102 A
What I want to create is something like this:
Order_id Brand A B C D E
100 A 1
100 B 1
100 C 1
101 D 1
101 D 1
102 E 1
102 A 1
102 C 1
102 A 1
Please let me know if this explanation is clear, and if there is a way to do it in Stata?
Thanks!
Related Posts with Generating new columns for each unique value of a categorical variable
graph catplot note overlaps with xaxisWhile creating some graphs I have discovered that a three line note overlaps with xaxis-title and (i…
Problem why time calculationsHey i'm wondering if anyone can help ? When i'm calculating the wait time(wait_time_new) i calcula…
Getting rid of overlapsHello Statlist I am fairly new to stata, and have run into a predicament in my data management. I …
Caluclate Value by using different months and yearsHello, I am currently working on an issue which I think is straight forward but somehow I am not ab…
Problem with dropping observations in longitudinal studyHi! I'm working with data collected in 2002 (round 1), 2007 (round 2) and 2017 (round 3). I want to…
Subscribe to:
Post Comments (Atom)
0 Response to Generating new columns for each unique value of a categorical variable
Post a Comment