Unfortunately,
in rankx[`i']
won't work either.
in `=rankx[`i']'
would work, but as mentioned
earlier
gen y = x[rankx]
is the way to do this, without looping.
Nick
[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Allan Reese
> Sent: 03 February 2004 14:01
> To: Stata distribution list
> Subject: RE: st: assignment by indexing
>
>
> On Tue, 3 Feb 2004, Nick Cox wrote:
> > Allan is incorrect ...
>
> Agreed, and I had completely misread Ben's problem. Also, the code I
> offered had a missing index
>
> > > loc nn = _N
> > > gen y = .
> > > forvalues i = 1/`nn' {
> > > replace y = x in rankx[`i']
> > > }
>
> The difference between this and "gen y = x[z]" is that rankx does not
> point to the element in x to be copied, but to the position
> in y where it
> is to go.
>
> * gen y[rankx] = x
>
> is the code that is disallowed - but by the time you read
> this it may be
> in the latest upgrade.
>
>
> *
> * 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/