
From  Rachel <academicgirl@gmail.com> 
To  statalist@hsphsun2.harvard.edu 
Subject  Re: st: RE: Utility to reduce vector length by a given number of elements 
Date  Fri, 9 Mar 2007 09:55:47 0500 
Thanks Nick, this works. I was hoping for a one step command (analagous to the functionality for strings in your renvars command) that did not involve computing the length, but apparently this doesn't exist. On 3/8/07, Nick Cox <n.j.cox@durham.ac.uk> wrote:
You may not know the length, but Stata does, so does this suit? . matrix a = (1,2,3,4,5,6,7,8,9,10) . mat list a a[1,10] c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 r1 1 2 3 4 5 6 7 8 9 10 . local last = colsof(a)  5 . matrix a = a[1, 1..`last'] . mat list a a[1,5] c1 c2 c3 c4 c5 r1 1 2 3 4 5 Nick n.j.cox@durham.ac.uk Rachel > Is there a Stata (rather than Mata) utility that will remove the last > n elements of a vector? Is there some way of doing this without > explicitly without knowing (or evaluating) the length of the vector? * * 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/
© Copyright 1996–2015 StataCorp LP  Terms of use  Privacy  Contact us  What's new  Site index 