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: weekly minus monthly data


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: weekly minus monthly data
Date   Tue, 13 Sep 2011 16:14:35 +0100

If you were worried about efficiency, you need not -generate- the variable -diff- but on other grounds you do need it to check what you have done.

Nick

On 13 Sep 2011, at 15:17, Nikolaos Kanellopoulos <nkkanel@yahoo.gr> wrote:

Dear all,

I have information regarding the month and year during which a rental contract was signed (sign_year & sign_month) and the year and week of the survey (surv_year & surv_week). I want to identify the contracts which were signed in less than three months from the week of the survey. My approach is to convert everything in monthly data and calculate the difference using the following:

gen date1 = mofd(dofw(yw( surv_year,surv_week )))
gen date2 = ym( sign_year , sign_month)
gen diff = date1 - date2
keep if diff<4

Two questions:
1) Is my approach correct. For a few individuals I get negative values. I suppose that this can occur if the week of the survey is within the month that the contract was signed.

2) Ii my approach is correct is there a better (more efficient) way to do this?

Kind regards
Nikos

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