Statalist


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

RE: st: Invalid file specification


From   "Hendri Adriaens" <Hendri@uvt.nl>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Invalid file specification
Date   Sun, 8 Jul 2007 17:16:43 +0200

Hi Michael, 

> 	I find that most Stata expressions that appear to 
> require an -if-  
> statement (as opposed to the -if- qualifier) can be transformed into  
> something that does not, and it usually works better as well.  In  
> your case, one possibility would be something like (note: untested!):
> 
> local zklist "cfd qds vfd tsa"
> foreach zk of local zklist {
>      clear
>      insheet a b c d e using "parsed_`zk'.txt", tab        // Inlezen
> 
>      [some more commands]
> }

Unfortunately, I can't guarantee `zk' is part of `bestand'.

> Notes:
> 
> 	1. My personal preference is to use the perfectly fine 
> carriage  
> return delimiter, rather than littering one's code with semicolons;   
> arguably in your case the use of -#delimit;- made it more difficult  
> to find your error.

In reality, the insheet command is very long. And I do prefer to end lines
explicitly.

> 	2. You don't say what "[some more commands]" 
> constitutes, but if you  
> don't need "x" later (which the above code presumes), then it's just  
> more overhead that (empirically) can lead to potential errors.

Of course, I don't need it, but I do need `zk' and `bestand'. And as Stata
doesn't have asociative arrays or something like that, I do need to do it
the way I presented. I can't do
local zklist "cfd qds vfd tsa"
foreach zk of local zklist {
as I won't know which is the filename that belongs to zk. Do you know a
better workaround?

> 	3. If you do not need the "bestand" local macro later, 
> then you can  
> follow the suggested code above.  Otherwise, within the loop you can  
> create a local macro as
> 
> local bestand = "parsed_`zk'.txt"

Unfortunately not, otherwise I could have used your code. I had to make this
workaround.

> 	4. It isn't clear to me that your -if- statements are 
> literally  
> invalid Stata code:  they merely did not return the values you  
> intended ("bestand" appears to have not been defined), which 
> then led  
> to problems down-stream.  But I doubt any error reporting convention  
> would have been able to identify your specific problem -- and the  
> suggestions of Austin & Kit on debugging are worth following.

It is obvious that if -{- has as syntax rule to ignore following material,
it should check for following material and produce a warning, or better, an
error if material is found. Why do you have syntax rules if you don't check
them and just run along until the whole thing breaks down completely to
produce a totally irrelevant error message by that time?

Best regards,
-Hendri.


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index