[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"victor michael zammit" <[email protected]> |

To |
<[email protected]> |

Subject |
st: Re: RE: Re:Is there any way ? |

Date |
Sun, 12 Sep 2004 23:26:47 +0200 |

I am using version 8.2 What I am trying to do is to isolate normally distributed variables closest to a mean of 50 and a sd of 10. The following clip is from a generation of 1000 such variables . 76 and 833 are variables that qualify to the relevant criteria .They are saved in my directory as a76.dta and a833.dta respectively . mean sd i > > --------------------------- > > 1. 49.96996 9.978514 76 ...................... > > 15. 50.08827 9.936735 833 What I need is a code that is capable of (for example) , renaming a76.dta , b76.dta & a833.dta , b833.dta , and thus being able to freely write over the previous a1.dta , a2.dta ..... a1000.dta , to handle other criteria , while conserving memory . Victor Michael Zammit ----- Original Message ----- From: Nick Cox <[email protected]> To: <[email protected]> Sent: Saturday, September 11, 2004 4:10 PM Subject: st: RE: Re:Is there any way ? > I am a bit lost on what you are trying to do > here. You seem to be generating samples from > a normal, but only wanting to keep them if they appear > really close to the target population > in the sense that sample mean and sample sd > are really close to the corresponding population > parameters. > > If that's right and memory is the issue, then > you should test each sample just after generation > and drop it immediately if it is not up to your > standards. Or equivalently you could do something > like this: > > gen prov = . > local j = 1 > qui while `j' < 100 > replace prov = 50 + 10 * invnorm(uniform()) > su prov > if inrange(r(mean),49.9,50.1)) & inrange(r(sd),9.9,10.1) > gen OK`j++' = prov > } > } > > That way, what you have in memory is just > the last sample generated > and all previous samples generated deemed OK > > By the way, standard advice in the Statalist FAQ is > > The current version of Stata is 8.2. Please specify if > you are using an earlier version; otherwise, the answer > to your question is likely to refer to commands or > features unavailable to you. > > Nick > [email protected] > > P.S. Stata is telling you why your code didn't work. First > time round it thinks that the > > [1] > > in > > use ai[1].dta, clear > > is a reference to weights. This also is puzzling. Presumably > you wouldn't try to -use- that dataset if you hadn't previously > saved it, but is that a legal filename with your (unstated) > operating system? > > -------------------------------------------------------------- > > victor michael zammit > > > the following dataset lists the 16 variables , out of 1000 normally > > distributed variable with mean 50 and standard deviation 10 > > , and then < > > keep if mean>49.9 & mean < 50.1 & sd > 9.9 & sd< 10.1 > . I > > would like to > > do this for different < set obs # > ,and 10,000 instead of > > 1000 , but > > memory becomes an issue .What I thought I could do , is to > > save variable i > > ' s under a different name, and then go to the next <set > > obs #> and < > > save,replace> over the previous 1000 or whatever variables . > > > > +---------------------------+ > > mean sd i > > --------------------------- > > 1. 49.96996 9.978514 76 > > 2. 49.92636 10.07861 118 > > 3. 49.97271 10.07149 122 > > 4. 50.07562 10.07239 218 > > 5. 49.94316 9.913686 220 > > --------------------------- > > 6. 50.02873 10.05811 346 > > 7. 50.01596 10.04384 442 > > 8. 50.00026 9.943673 513 > > 9. 49.91186 9.95947 533 > > 10. 50.00311 10.00525 629 > > --------------------------- > > 11. 50.09705 9.929688 653 > > 12. 49.98079 10.04592 678 > > 13. 49.93727 9.962771 686 > > 14. 49.98563 10.07247 694 > > 15. 50.08827 9.936735 833 > > --------------------------- > > 16. 49.97584 10.05994 854 > > > > > > I experimented with a loop : > > > > > > . local i = 1 > > > > . while `i'<= _N { > > 2. use ai[`i'].dta,clear > > 3. save b`i',replace > > 4. local i = `i'+1 > > 5. } > > weights not allowed > > r(101); > > > > but it did not work > > Is there a way I could do this ? > > * > * For searches and help try: > * http://www.stata.com/support/faqs/res/findit.html > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: RE: Re:Is there any way ?***From:*"Nick Cox" <[email protected]>

- Prev by Date:
**st: RE: -forvalues- and decimal numbers in the numlist** - Next by Date:
**st: blabel(group) for bar graphs** - Previous by thread:
**st: RE: Re:Is there any way ?** - Next by thread:
**st: RE: Tabulate and date format display** - Index(es):

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