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]

From |
Rijo John <rmjohn@gmail.com> |

To |
stata <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: table command returns different values every time |

Date |
Thu, 12 Dec 2013 11:47:36 +0530 |

I realized that it is not the code itself that is causing the problem, but something that is happening before. Because, when I ran this code independently on the data with only the variables used in the code, the results are same all the time. I need to figure out what else is going on before this particular code. I will update if I find the answer. Thank you for your time. Regards, Rijo. On Thu, Dec 12, 2013 at 11:14 AM, Richard Williams <richardwilliams.ndu@gmail.com> wrote: > I am with Nick -- I do not see any reason why you should be having problems. > My theory is that there is something going on in the earlier code we aren't > seeing. Are you, for example, generating a random variable, or drawing a > random subsample? If so, you might need to set the seed first, e.g. start > your code off with > > set seed 123456 > > > At 11:07 AM 12/11/2013, Nick Cox wrote: >> >> There are at least two problems in understanding this. >> >> First, and obviously, we don't have your data to check this (and you >> don't provide an alternative reproducible example). >> >> Second, and more of a challenge, you are calling up -table- to show >> some means in cells of a cross-classification. I may be missing >> something, but there should be no way that depends on the sort order >> of your data. Also, as you imply, that should be reproducible any way. >> >> Any chance of seeing an example we can reproduce? >> Nick >> njcoxstata@gmail.com >> >> >> On 11 December 2013 14:36, Rijo John <rmjohn@gmail.com> wrote: >> > Dear Statalist, >> > >> > I am running the following code to generate a certain table. Every >> > time restart stata and run the code it returns results wherein some of >> > the values are slightly different compared to the previous run. I am >> > talking about differences at 2nd, 3rd or higher decimals. What can I >> > do to make this stable? I think the difference is happening may be >> > because the sorting order is changing every time I restart stata. It >> > doesn't change within the same session. If I don't give the sort >> > command in between it still changes every time I run the program. >> > >> > <---Code Begins ---> >> > local fruit "Apple Apricot Bananas Mango Orange" >> > local num "1 2 3 4 5" >> > local n : word count `fruit' >> > forvalues i=1/`n'{ >> > sort id, stable >> > local a : word `i' of `fruit' >> > local b : word `i' of `num' >> > gen `a'=0 >> > replace `a'=var1 if fruit==`b' >> > table State sex if ag==2 [pw=mult], c(mean `a') >> > } >> > <---Code Ends ---> >> > * >> > * 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/ > > > ------------------------------------------- > Richard Williams, Notre Dame Dept of Sociology > OFFICE: (574)631-6668, (574)631-6463 > HOME: (574)289-5227 > EMAIL: Richard.A.Williams.5@ND.Edu > WWW: http://www.nd.edu/~rwilliam > > > * > * 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/

**References**:**st: table command returns different values every time***From:*Rijo John <rmjohn@gmail.com>

**Re: st: table command returns different values every time***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: table command returns different values every time***From:*Richard Williams <richardwilliams.ndu@gmail.com>

- Prev by Date:
**RE: st: Fitting a linear regression where coefficients are bounded proportions** - Next by Date:
**Re: st: Fitting a linear regression where coefficients are bounded proportions** - Previous by thread:
**Re: st: table command returns different values every time** - Next by thread:
**Re: st: table command returns different values every time** - Index(es):