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: RE: RE: RE: Counting Number of Week-Days


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: RE: RE: Counting Number of Week-Days
Date   Wed, 8 Sep 2010 10:59:59 +0100

You could extend Martin's application by just adding a further constraint using -tin()- or -twithin()-. 

Nick 
[email protected] 

Martin Weiss

***********
clear*

inp str10 date
4apr2010
15apr2010
end

gen mydate=date(date, "DMY")
set obs `=mydate[2]-mydate[1]+1'
replace mydate=mydate[1]+_n-1

form mydate %td
l
cou if !inlist(dow(mydate), 0, 6)
***********

Simone Peart Boyce

Thanks Nick.  That helps somewhat.  I actually have two dates that I would
like 
to count the number of weekdays that transpire between them.  If for
example, 
date1=4apr2010 and date2=15apr2010, how can I easily count the number of 
weekdays between those two dates?

Nick Cox <[email protected]> 

I'm guessing that "weekdays" means for you Monday-Friday. Given daily dates,
say 
in a variable -date-, -dow(date)- is 0 ... 6 on Sunday ... Saturday.   Thus
the 
examples   . count if !inlist(dow(date), 0, 6)   . count if
inrange(dow(date), 
1, 5)   . egen whatever = total(inrange(dow(date)), by(somethingelse)   show

various techniques that may be useful. If this doesn't help, you may need to
be 
more precise about your set-up.   

Simone Peart Boyce  

I'm trying to determine the number of week-days between two dates. 
Is 
there an  easy way to do this in 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