Hi,
I need to reshape my dataset wide. I've been on many forums and have used the help function in stata, yet I'm still having some issues. Here's how my data currently looks:
Month Dr. Frequency
Apr2022 Smith 17
Apr2022 Nelson 84
May2022 Smith 12
May2022 Nelson 8
Jun2022 Smith 100
Jun2022 Nelson 51
I'd like to reshape wide and format it as:
Dr. Apr2022 May2022 Jun2022
Smith 17 12 100
Nelson 84 8 51
Here's my current code:
egen x = group(Month Dr.)
sort x
quietly by x: gen test=_n
reshape wide Month Dr. Frequency, i(x) j(test)
Any suggestions would be very help.
Thank you
I need to reshape my dataset wide. I've been on many forums and have used the help function in stata, yet I'm still having some issues. Here's how my data currently looks:
Month Dr. Frequency
Apr2022 Smith 17
Apr2022 Nelson 84
May2022 Smith 12
May2022 Nelson 8
Jun2022 Smith 100
Jun2022 Nelson 51
I'd like to reshape wide and format it as:
Dr. Apr2022 May2022 Jun2022
Smith 17 12 100
Nelson 84 8 51
Here's my current code:
egen x = group(Month Dr.)
sort x
quietly by x: gen test=_n
reshape wide Month Dr. Frequency, i(x) j(test)
Any suggestions would be very help.
Thank you
Comment