I am dealing with data with information of different candidates, the results of each candidate is distributed by class 1, 2, 3, 4
Candidate A Name | Sex | Votes |Candidate B Name | Sex | Votes | Candidate C Name | Sex | Votes | Candidate D Name | Sex | Votes
Class 1
Class 2
Class 3
Class 4
Firstly, I wish to group the columns of the information of a candidate, such that
Group A [ contains Candidate A Name | Sex | Votes of Candidate A]
Group B [ contains Candidate B Name | Sex | Votes of Candidate B]
Group C [ contains Candidate B Name | Sex | Votes of Candidate C]
After that, I wish to compare the number of votes of each candidate, and to Generate the name of the candidate only with the Highest Result into a new column
For example, if Candidate D obtains highest number of vote, name fo Candaidate D will be generate in a new column
Thank you in advance
Related Posts with How to group several columns?
Plotting a likelihood surfaceDear all Let's say I have a linear model with two predictors: Code: program linear ar…
Define a binary variable using and / orDear all, I have a panel data set. Each observation is organized by firmId and year. Some other vari…
Can PPML coefficients be analyzed as elasticities? Gravitational ModelDear, I am using PPML to analyze the impact of institutions on exports. My question is, can coeffi…
How to keep whole group with a variable including 3 valuesHi I have a panel data with firm and year. I want to keep only firms that headquartered in US and at…
Extracting a month/year variable from a dateI'm new to Stata and I have a dumb question. I have a date variable (indexdate) with the format %tdD…
Subscribe to:
Post Comments (Atom)
0 Response to How to group several columns?
Post a Comment