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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

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

Subject |
RE: st: Re: multiple )))brackets, is there a more efficient way? |

Date |
Tue, 25 May 2004 15:28:42 +0100 |

On using -merge- in this way, see also http://www.stata.com/support/faqs/data/characteristics.html http://www.stata.com/support/faqs/data/selectid.html Nick n.j.cox@durham.ac.uk > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of > Ulrich Kohler > Sent: 25 May 2004 15:20 > To: statalist@hsphsun2.harvard.edu > Subject: Re: st: Re: multiple )))brackets, is there a more efficient > way? > > > It might still be a matter of taste, but, for many codings I think > michael.blasniks approach is very powerfull---at least for > documentation. > Also remember that you can create your dataset within the > original do-file, if > you don't want to split the documentation into different files: > > -----------------------mydofile.do > use nation, clear > <commands> > sort nation > > // Create Origin-Variable > preserve > input nation origin > 1 3 > 2 3 > 3 3 > 4 3 > 5 2 > 6 2 > 7 2 > 8 1 > ... > 141 10 > end > sort nation > save origin, replace > restore > > // Merge Origin Variable to nation-data > merge nation using origin > > exit > ---------------------------------------------- > > > Adrian.P.Mander@gsk.com wrote: > > OR just use a recode or is this missing the point? > > > > gen origin = natio > > recode origin 3=7 8 12 69 139 141=10 14=8 ... etc > > > > cheers > > Ade > > > > > > > > > > "Michael Blasnik" > > <michael.blasnik@verizon. > > net> > > To: > > statalist@hsphsun2.harvard.edu Sent by: > > owner-statalist@hsphsun2. cc: > > harvard.edu > Subject: st: Re: > > multiple )))brackets, is there a more efficient way? > > > > > > 25-May-2004 14:45 > > Please respond to > > statalist@hsphsun2.harvar > > d.edu > > > > > > > > > > > > The suggestion to use inlist may be a step in the right > direction, but if > > you have a coding for every county in the world or any > list with more than > > a few dozen codings, I would think that you should create a > dataset with > > the > > codings (often this coding information is available in a > way that makes the > > dataset creation fairly straightforward) and then use > -merge- to bring them > > in. > > > > sort nation > > merge nation using nationcodes > > > > You can always list the nationcode file to document what > the mapping is. > > > > Michael Blasnik > > michael.blasnik@verizon.net > > > > ----- Original Message ----- > > From: "Annelies Vos" <a.vos@erasmusmc.nl> > > To: <statalist@hsphsun2.harvard.edu> > > Sent: Tuesday, May 25, 2004 2:35 AM > > Subject: st: multiple )))brackets, is there a more efficient way? > > > > > Dear all, > > > in the FAQs I found the following very useful recommendation: > > > instead of: > > > . generate byte a = 1 if y <= 20 > > > . replace a = 2 if y > 20 & y <= 30 > > > . replace a = 3 if y > 30 & y <= 40 > > > . replace a = 4 if y > 40 & y <. > > > > > > do the following: > > > > > > . #delim ; > > > . generate byte a = > > > cond(y<=20, 1, > > > cond(y<=30, 2, > > > cond(y<=40, 3, > > > cond(y<., 4, > > > . )))); > > > > > > However, the variable I want to use it for (nationality) has many > > > values (every country in the world), which should be recoded into > > > countrygroups. I don't really like the idea of having to count the > > > number of "opening brackets": "(" , to know with how many "closing > > > brackets": ")" I should end. Is there any easier solution > for this? > > > > > > to explain a piece of my syntax: > > > > #delim; > > > > generate byte origin = > > > > cond(natio==3, 7, > > > > cond(natio==8, 10, > > > > cond(natio==12, 10, > > > > cond(natio==14, 8, > > > > cond(natio==28, -9, > > > > cond(natio==54, 6, > > > > cond(natio==69, 10, > > > > cond(natio==82, 8, > > > > cond(natio==139, 10, > > > > cond(natio==141, 10, > > > > > > ...etcetera > > > > > > ...which I would like to end on another way than: > > > > . )))))))))) > > > > > > Thanks for any suggestions, > > > > > > Annelies Vos > > > > * > > * 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/ > > -- > kohler@wz-berlin.de > +49 (030) 25491-361 > > > * > * 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/

- Prev by Date:
**recode, was: Re: st: Re: multiple )))brackets, is there a more efficient way?** - Next by Date:
**st: Re: recode,** - Previous by thread:
**st: RE: Creating a series of random number** - Next by thread:
**st: Re: recode,** - Index(es):

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