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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

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

Subject |
st: RE: RE: RE: RE: reallocating variables within observations |

Date |
Tue, 18 Nov 2008 14:34:06 +0100 |

Look under the hood of -ssc d fixsort- (which seems to do exactly what you want), and you see that it also uses temps: -tempvar-s and -h clonevar- from official Stata instead of -tempfile-s. It is an extremely convenient command in the rare cases where users want what you seem to be asking for... HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Linn Renée Naper Sent: Tuesday, November 18, 2008 1:59 PM To: statalist@hsphsun2.harvard.edu Subject: st: RE: RE: RE: reallocating variables within observations Thanks, I will. Right know I'm not sure if I need it, but interesting to look into anyway I think. It is probably possible to do this in several steps using merge, new files etc, but that's not how I want to do it if I can do it with a "simple" command. Tnx again. -----Opprinnelig melding----- Fra: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] På vegne av Nick Cox Sendt: 18. november 2008 12:22 Til: statalist@hsphsun2.harvard.edu Emne: st: RE: RE: reallocating variables within observations Linn's statement is an understatement. This kind of allocation is strong stuff. See -cquantile- and -fixsort- on SSC for what may be answers to your question, and always keep copies of the data as they are now. Nick n.j.cox@durham.ac.uk Martin Weiss It is not really clear what you want (in particular: what role does the "y" play?) But here is a quick and dirty solution: ************ clear* input var1 var2 1 2 3 1 4 3 5 1 5 3 4 2 3 4 6 4 6 1 2 1 2 2 end l, sepby(var1) noo sort var1 preserve tempfile new keep var1 save `new' restore drop var1 sort var2 merge using `new' order var1 var2 l ************* Linn Renée Naper I have two variables x1 and x2 identified by the variable y. Then I sort the data on x1, so that the observation with the lowest value of x1 comes first. How can I tell stata to allocate the x2 values so that the lowest x2 is assigned the observation with the lowest x1 etc? This is not the same as sorting by x1 and x2, as I need to reallocate the variables within observations. * * 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/

**Follow-Ups**:**st: RE: RE: RE: RE: RE: reallocating variables within observations***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: reallocating variables within observations***From:*Linn Renée Naper <linn.naper@ecgroup.no>

**st: RE: reallocating variables within observations***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: RE: RE: reallocating variables within observations***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**st: RE: RE: RE: reallocating variables within observations***From:*Linn Renée Naper <linn.naper@ecgroup.no>

- Prev by Date:
**st: RE: RE: RE: reallocating variables within observations** - Next by Date:
**st: How to Export first-stage of IV (e.g. with ivreg2) to Latex (e.g. with outreg2) ?** - Previous by thread:
**st: RE: RE: RE: reallocating variables within observations** - Next by thread:
**st: RE: RE: RE: RE: RE: reallocating variables within observations** - Index(es):

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