Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: Need Help using putexcel command for tabulate in survey setting


From   Joe Canner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: RE: Need Help using putexcel command for tabulate in survey setting
Date   Mon, 7 Apr 2014 12:28:51 +0000

Anwar,

Sorry, ignore my advice and see some better solutions in response to your post on statalist.org.

Regards,
Joe

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Joe Canner
Sent: Sunday, April 06, 2014 10:02 AM
To: [email protected]
Subject: st: RE: Need Help using putexcel command for tabulate in survey setting

Anwar,

This is not a problem with -putexcel-, but rather of how to get the numbers you want out of the -tabulate- command. The matrices you are using are specific to -svy- but are not necessarily designed for using -svy- with -tabulate- in particular.  I'm not sure why it is difficult to get weighted counts in this situation (or perhaps I'm missing something).  One thing you can try is to run -tabulate- without -svy-:

. tabulate race [fw=finalwgt] if sex==1, matcell(y) matrow(x)
. matrix list y
. matrix list x

I'm not sure at the moment how to get the text values of race into a matrix.  I will think about that some more and get back to you.

BTW, I'm not sure I understand the purpose of the two matrix commands right before the -putexcel- statement, since you don't refer to -x- and -y- in the -putexcel- statement.

Regards,
Joe Canner
Johns Hopkins University School of Medicine
________________________________________
From: [email protected] [[email protected]] on behalf of Dudekula, Anwar [[email protected]]
Sent: Saturday, April 05, 2014 12:58 PM
To: [email protected]
Subject: st: Need Help  using  putexcel command  for tabulate  in survey setting

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 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.



Thank you,
Yours Sincerely,
Anwar Dudekula




*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index