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: RE: Calendar weeks


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: RE: Calendar weeks
Date   Wed, 15 Feb 2012 09:44:15 +0000

This post crossed with mine from which you can see that the loop over
observations n'est pas obligatoire.

(The list is called Statalist, not Statlist.)

Nick

On Wed, Feb 15, 2012 at 9:26 AM, Charles Vellutini
<[email protected]> wrote:
> Dear Statlisters,
>
> Follow-up: I am sure there are more elegant solutions, but this seems to work ("lundi_sem" is the Monday of the week "date"  belongs to):
>
> gen lundi_sem=.
> format lundi_sem %td
>
> local N = _N
> forvalues i = 1/`N' { //cette boucle copie date du lundi semaine sur chaque jour de la semaine concernée
>        if dow[`i'] == 1 {
>        qui replace lundi_sem = date in `i'
>                                                }
>        else if dow[`i'] == 0 {
>        qui replace lundi_sem = date - 6 in `i'
>        }
>        else {
>        qui replace lundi_sem = date - dow +1 in `i'
> }
> }
>

*
*   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