Hi Statlists,
I have a (very simple) question regarding labeling a group variable, using a binary variable column. I could not share the data here due to the confidentiality of the dataset, but my data looks like follows:
I want to categorize a person by year and month. As you can see, there is no problem for individual A and B as they are categorized perfectly by the the Status variable. The problem occurs at an individual C in month 2 and 3 as a person has mixed status. Eventually, I want to collapse the data to look like follows:
Question: How do I create the table like this?
I have tried `bysort` and `egen`, but there is no way using these two command to detect the different between rows. What other commands should I try to create the table like this?
Thank you for reading this question. I would appreciate any advice/suggestions the community may have!
Best,
Kob
I have a (very simple) question regarding labeling a group variable, using a binary variable column. I could not share the data here due to the confidentiality of the dataset, but my data looks like follows:
Person | Year | Month | Status |
A | 2019 | 1 | 0 |
A | 2019 | 2 | 0 |
A | 2019 | 3 | 0 |
B | 2019 | 1 | 1 |
B | 2019 | 2 | 1 |
B | 2019 | 3 | 1 |
C | 2019 | 1 | 0 |
C | 2019 | 2 | 0 |
C | 2019 | 2 | 1 |
C | 2019 | 3 | 0 |
C | 2019 | 3 | 1 |
C | 2019 | 4 | 1 |
Person | Year | Month | Status |
A | 2019 | 1 | 0 |
A | 2019 | 2 | 0 |
A | 2019 | 3 | 0 |
B | 2019 | 1 | 1 |
B | 2019 | 2 | 1 |
B | 2019 | 3 | 1 |
C | 2019 | 1 | 0 |
C | 2019 | 2 | 2 |
C | 2019 | 3 | 2 |
C | 2019 | 3 | 1 |
I have tried `bysort` and `egen`, but there is no way using these two command to detect the different between rows. What other commands should I try to create the table like this?
Thank you for reading this question. I would appreciate any advice/suggestions the community may have!
Best,
Kob
Comment