Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: RE: Calendar weeks


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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
<charles.vellutini@ecopa.com> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index