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

From |
"Carlo Lazzaro" <carlo.lazzaro@tiscalinet.it> |

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

Subject |
st: R: RE: how to work around -levelsof- limits with Stata 9.2/SE? |

Date |
Tue, 14 Oct 2008 14:51:42 +0200 |

Dear Martin, thanks a lot again for your further kind reply. Unfortunately, my "a" values are not regularly spaced, since they are the results of a Monte Carlo simulation. Thanks a lot again and Kind Regards, Carlo -----Messaggio originale----- Da: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Martin Weiss Inviato: martedì 14 ottobre 2008 13.25 A: statalist@hsphsun2.harvard.edu Oggetto: st: RE: how to work around -levelsof- limits with Stata 9.2/SE? "levelsof may hit the limits imposed by your Stata. However, it is typically used when the number of distinct values of varname is modest." (from -h levelsof-). I should have anticipated this problem. Are the levels of your "a" in any way regularly spaced (to enable application of -forvalues-)? HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Carlo Lazzaro Sent: Tuesday, October 14, 2008 12:44 PM To: statalist@hsphsun2.harvard.edu Subject: st: how to work around -levelsof- limits with Stata 9.2/SE? Dear Statalisters, I have performed successfully Martin's helpful syntax using -levelsof- on a sample of 20 distinct values for var a. However, when I tried to repeat the loop for the total 10,000 levels of var a I got an error message(admittedly, the recommended limit for -levelsof- is a modest number of distinct values for varlist, so I cannot complain about this useful ado.file). Is there any way to work this around? Please find below the command lines I typed along with the error message I got at the end of the sequence: . levelsof ICER_round, loc(levels) *around 10,000 levels are still reported after rounding to the nearest whole number . foreach lev of local levels { 2. g result`lev'=` ICER_round'* Delta_Q- Delta_C 3. } invalid syntax r(198); Thanks a lot for your kindness and for your time. Kind Regards, Carlo -----Messaggio originale----- Da: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Carlo Lazzaro Inviato: martedì 14 ottobre 2008 11.46 A: statalist@hsphsun2.harvard.edu Cc: 'Martin Weiss' Oggetto: st: R: RE: a possible - foreach - question? Dear Martin, thanks a lot for your precious hint. It works perfectly. Thanks a lot again and Kind Regards, Carlo -----Messaggio originale----- Da: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Martin Weiss Inviato: martedì 14 ottobre 2008 11.04 A: statalist@hsphsun2.harvard.edu Oggetto: st: RE: a possible - foreach - question? ***************+ sysuse auto, clear *get the levels of mpg (a in your xmpl) levelsof mpg, loc(levels) *loop through them, create new vars along the way *price takes place of b in your code, headroom is c foreach lev of loc levels{ g result`lev'=`lev'*price- headroom } *get the means from -summarize- su result* *************** HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Carlo Lazzaro Sent: Tuesday, October 14, 2008 10:50 AM To: statalist@hsphsun2.harvard.edu Subject: st: a possible - foreach - question? Dear Statalisters, I have three variables (a; b; C with 10,000 observations each) in long format. For each value of a I would like to obtain the following one: (a1 * b1) - c1 . . . . (a1*b10,000)-c10,000; Repeat the above reported would-be 10,000 times (i.e., from a1 to a10,000) Create a new variable d in which the mean of each one of the 10,000 iterations are stored and can be displayed. I suppose there's way of doing this with Stata 9.2/SE, but I cannot figure out the proper syntax. Thanks a lot for your kindness and for your time. Kind Regards, Carlo * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/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/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/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/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/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/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**R: st: RE: how to work around -levelsof- limits with Stata 9.2/SE?** - Next by Date:
**R: st: RE: how to work around -levelsof- limits with Stata 9.2/SE?** - Previous by thread:
**R: st: RE: how to work around -levelsof- limits with Stata 9.2/SE?** - Next by thread:
**st: even categories** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |