I am using the following command to export a table into an Excel file, where I want to see the gender distribution by state. Gender is a binary variable (1=female, 0=male):
collect get: table state gender, stat(freq) stat(percent gender, across(gender))
putexcel A59 = collect
I used this command before with a different dataset, and it worked perfectly, but this is what I get when I run the command this time:
gender
male female Total
state
Banadir
Frequency 171 186 357
Percent 0.00 100.00 100.00
Galmudug
Frequency 107 103 210
Percent 0.00 100.00 100.00
Hirshabelle
Frequency 115 143 258
Percent 0.00 100.00 100.00
Jubaland
Frequency 122 137 259
Percent 0.00 100.00 100.00
South_West
Frequency 176 181 357
Percent 0.00 100.00 100.00
Total
Frequency 691 750 1,441
Percent 0.00 100.00 100.00
I tried to change the format of the binary variable from 0 to 2 for male participants, but the same command gave completely wrong percentages. I also tried to change the format of the gender variable from float to byte, but this did not work either.
How can I fix this? I searched for similar examples, but I could not find any solutions online for this.
Thanks a million!
collect get: table state gender, stat(freq) stat(percent gender, across(gender))
putexcel A59 = collect
I used this command before with a different dataset, and it worked perfectly, but this is what I get when I run the command this time:
gender
male female Total
state
Banadir
Frequency 171 186 357
Percent 0.00 100.00 100.00
Galmudug
Frequency 107 103 210
Percent 0.00 100.00 100.00
Hirshabelle
Frequency 115 143 258
Percent 0.00 100.00 100.00
Jubaland
Frequency 122 137 259
Percent 0.00 100.00 100.00
South_West
Frequency 176 181 357
Percent 0.00 100.00 100.00
Total
Frequency 691 750 1,441
Percent 0.00 100.00 100.00
I tried to change the format of the binary variable from 0 to 2 for male participants, but the same command gave completely wrong percentages. I also tried to change the format of the gender variable from float to byte, but this did not work either.
How can I fix this? I searched for similar examples, but I could not find any solutions online for this.
Thanks a million!
Comment