there is data set
after giving reshape wide command
bysort Id :gen ab=_n
replace ab=0 if ab==.
reshape wide age antibiotics, i(id) j(ab)
the data Looks like
Now I want single age and single antibiotics column without the duplication of ID.
Please suggest what to do in Stata 14
Id | age | antibiotics |
1 | 23 | 2 |
2 | 24 | 1 |
2 | 34 | 1 |
3 | 32 | 2 |
3 | 22 | 1 |
4 | 24 | 2 |
4 | 23 | 2 |
4 | 25 | 2 |
4 | 23 | 1 |
4 | 25 | 1 |
bysort Id :gen ab=_n
replace ab=0 if ab==.
reshape wide age antibiotics, i(id) j(ab)
the data Looks like
id | age1 | age2 | age3 | age4 | age5 | antibiotics1 | antibiotics2 | antibiotics3 | antibiotics4 | antibiotics5 | |
1 | 23 | 2 | |||||||||
2 | 24 | 34 | 1 | 1 | |||||||
3 | 32 | 32 | 2 | 1 | |||||||
4 | 24 | 23 | 25 | 23 | 25 | 2 | 2 | 2 | 1 | 1 |
Now I want single age and single antibiotics column without the duplication of ID.
Please suggest what to do in Stata 14
Comment