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]

st: AW: confirm


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: confirm
Date   Wed, 18 Aug 2010 12:53:22 +0200

<> 

Just -capture- the -confirm- statement, and condition on the return code

*************
sysuse auto, clear
foreach var in newvariable price weight{
capt conf new variab `var'
di in red _rc
}
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von Dimitri Szerman
Gesendet: Mittwoch, 18. August 2010 12:25
An: statalist
Betreff: st: confirm

Hello,

Here's what I'm trying to do. I have a directory with many files, one for
each weekday of the year. Some files are missing, and I want to find out
which files are missing. The filenames make it easier to use a loop and
confirm, and I came up with this:

local YEAR  2006
local MONTH 01 02 03 04 05 06 07 08 09 10 11 12
local DAY 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22
23 24 25 26 27 28 29 30 31

 foreach Y of local YEAR  {
 foreach M of local MONTH {
 foreach D of local DAY {

 scalar day = mdy(`M',`D',`Y')
 scalar satsun = dow(day)

if satsun!=0 & satsun!=6 & satsun!=. {
confirm file "`Y'`M'`D'.csv"
}

 }
 }
 }

Now, my problem is, this code will stop on the first missing file. What I'd
like is to have is Stata printing a list of missing files. Any ideas would
be much appreciated.

Many thanks,
Dimitri
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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