Statalist The Stata Listserver


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

Re: st: Dropping Subset of Variables


From   "Sergiy Radyakin" <[email protected]>
To   <[email protected]>
Subject   Re: st: Dropping Subset of Variables
Date   Thu, 29 Mar 2007 14:48:35 +0200

use NFHS98_school
drop hvidx_02-hvidx_46
forvalues x= 101/117 {
drop hv`x'_02-hv`x'_46
}

Sergiy


----- Original Message ----- From: "Michael Blasnik" <[email protected]>
To: <[email protected]>
Sent: Thursday, March 29, 2007 2:38 PM
Subject: Re: st: Dropping Subset of Variables



The forvalues command is specified incorrectly. You will also want to change the max value to 46 and have the loop start at 2, not 1

forvalues x= 2/46 {
drop hvidx_0`x'
}

You will also want to have more drop lines to list the other variable stubs you want dropped. but only you know the full pattern of variable names that you want to be dropped...

Michael Blasnik

----- Original Message ----- From: "Gauri Khanna" <[email protected]>
To: <[email protected]>
Sent: Thursday, March 29, 2007 8:18 AM
Subject: Re: st: Dropping Subset of Variables



Dear Neil,

I tried out the command but I get an error of invalid syntax


forval x in 1/6{
 2.        drop hvidx_0`x'
 3. }
invalid syntax
r(198);

*
* 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