Statalist


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

Re: st: sub-dataset by variable numbers


From   "Sebastian F. B�chte" <[email protected]>
To   [email protected]
Subject   Re: st: sub-dataset by variable numbers
Date   Tue, 2 Oct 2007 13:51:49 +0200

Jianan

I do not think there is a direct command which will help you to
achieve what you would like. But, you could try the following:

unab vlist : _all
//keep 3rd to 6th variable from dataset in memory
keep `: word 3 of `vlist'' - `: word 6 of `vlist''

This will read all variable names into a local macro (vlist) and then
uses local extended functions to extract numbered elements from this
macro. For more information look at: -help unab- and -help
extended_fcn-

Regards
Sebastian

2007/10/2, Jian'an Luan <[email protected]>:
> Dear Statalist
>
> I wonder if I can select a sub-dataset by variables without given
> variable names but using variable numbers, something like the command
> when select a sub-dataset by observations ".keep if _n>1001 & _n<2000".
>
> Any help will be appreciated.
>
> Jianan
>
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index