Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: confirm


From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   RE: st: confirm
Date   Tue, 8 Mar 2005 08:52:06 -0000

The other option is to confirm the variable _doesn't_ exist - this will always look for the exact name, i.e.

forval i=1/52 {
   cap confirm new var x`i'
   if _rc==0 {
      gen x`i'=.
   }
}

BTW, -set varabbrev- was added in an update (5 October 04), so if you can't find it you will need to type -update query- and follow the update instructions.

David

-----Original Message-----
From: Philip Ryan [mailto:[email protected]]
Sent: 08 March 2005 06:46
To: [email protected]
Subject: Re: st: confirm


Keith,

use  -set varabbrev off-

. sysuse auto
(1978 Automobile Data)

. set varabbrev on

. confirm var mak

. set varabbrev off

. confirm var mak
variable mak not found
r(111);


see -help set-

Phil


Quoting Keith Dear <[email protected]>:

> How do I confirm that a variable exists with exactly the name I state, not
> as an abbreviation? If I say -cap confirm var x3- but I have a variable
> x30, then I get _rc==0 even though x3 does not exist.
>
> I'll give the context, in case there's a better way. Here's what I am
> trying to do:
>
> forval i=1/52 {
>    cap confirm var x`i'
>    if _rc!=0 gen x`i'=.
> }
>
> This NEARLY works...
>
> ==========================================================
> Dr Keith B.G. Dear
> Senior Fellow in Biostatistics
> National Centre for Epidemiology and Population Health (NCEPH)


-- 
Philip Ryan
Associate Professor
Department of Public Health
University of Adelaide
5005 South Australia
AUSTRALIA
CRICOS Provider Number 00123M
-----------------------------------------------------------
This email message is intended only for the addressee(s)
and contains information that may be confidential and/or
copyright.  If you are not the intended recipient please
notify the sender by reply email and immediately delete
this email. Use, disclosure or reproduction of this email
by anyone other than the intended recipient(s) is strictly
prohibited. No representation is made that this email or
any attachments are free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.
*
*   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