Hi Everyone, I need help with exporting results from tabulate command by using putexcel command in survey setting I have a survey datasets with a string variable.I am trying to perform oneway tabulation and use putexcel My goal is to put the various string values (for the string variable) in column A and their weighted count in column B in excel sheet. To demonstrate it, I am using the nhanes dataset and the code is as follows
***************code Start*********************************
webuse nhanes2f, clear
decode race, gen(s_race) // we generate a string varaible for demonstration purpose
svy, subpop(sex): tabulate s_race, count missing format(%11.3g) // I wanted to use tabulate s_race
* Now I am trying to use the estimated results to put into the excel cells
mat x = e(b)'
mat y=e(Rows)'
putexcel A1=("STRING_VAR") B1=("COUNT") A2=matrix(e(Rows)') B2=matrix (e(b)') using results , modify
***************code End********************************* *
however , I get the excel file with following results.
STRING_VAR COUNT
1 0.095615161
2 0.025368614
3 0.879016225
However What I am looking for is something like
STRING_VAR COUNT
Black Weighted count of Black
White Weighted count of White
Other Weighted count of Other
Can anyone of the stata gurus in this forum help me getting the desired results.
I thank you very much for your time and effort. Sorry:I posted this in old statalist and then realized that the list is being migrated to the new statalist.
Thank you,
Yours Sincerely,
Anwar Dudekula
Comment