Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: -confirm variable- does not accept varlist (wildcards)


From   Joe Canner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: -confirm variable- does not accept varlist (wildcards)
Date   Thu, 5 Sep 2013 15:29:02 +0000

Nick,

I'm intrigued by your last sentence in #2.  Are you've saying you've never had occasion to use wildcards in varlists, or that there are alternatives?  For example, suppose you wanted to do something with all system-generated variables _*, knowing that these might be scattered around the dataset and not contiguous.  How would you do that without wildcards?

Laszlo,

You said " I am not sure how confirm *should* work with wildcards".  According to the -confirm- documentation, not only should -confirm var- work with a varlist, but they even give an example of using it with multiple variables.  From what I can tell, it throws an error if any one or more of the variables listed is not the desired type.  So, I think you have a legitimate gripe.

Regards,
Joe Canner
Johns Hopkins University School of Medicine

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Thursday, September 05, 2013 11:02 AM
To: [email protected]
Subject: Re: st: -confirm variable- does not accept varlist (wildcards)

On the question:

1. It seems that you are right. -confirm- does not support wildcard varlists.

2. But I've never noticed this before. That just means what it says, but in 20 years of writing a fair number of programs, I've never wanted to try out a wildcard varlist.
Nick
[email protected]


On 5 September 2013 15:30, Nick Cox <[email protected]> wrote:
> . sysuse auto, clear
> (1978 Automobile Data)
>
> . confirm var m*
> m ambiguous abbreviation
> r(111);
>
> . unab m : m*
>
> . confirm var `m'
> Nick
> [email protected]
>
>
> On 5 September 2013 15:18, László Sándor <[email protected]> wrote:
>> Just a note about something that bit me hard in the last few days:
>> contrary to the help file, -confirm variable- did not take a string I 
>> meant as a varlist in the form of "q_*" but produced an error that * 
>> is invalid. As the typical use case is with -capture- and -if (_rc)-, 
>> I did not notice that the wrong fork of my code was executed until 
>> quite some time.
>>
>> To be clear, I am not sure how confirm *should* work with wildcards 
>> or multiple variables anyway, I know. And it does accept abbreviations.
>> So "q_" does work, and it is even clearer about my intentions. And I 
>> should have tested the code anyway. And I probably should have used 
>> more specific -if (_rc==)- specifications to distinguish the variable 
>> genuinely missing from other errors.
>>
>> That said, it does not feel right to be bitten by a casual "varlist"
>> specified in the documentation actually not complying with what 
>> varlists are. A few weeks ago I had a similar issue with ranges of 
>> variables in the keepusing() option of -merge-.
>>
>> Thanks,
>>
>> Laszlo
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index