Statalist


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

st: AW: re: Creating number of days per month


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: re: Creating number of days per month
Date   Mon, 2 Nov 2009 17:13:41 +0100

<> 

Just wondering: Would the -tsfill- line (which adds observations for every
single day spent by every single patient in the dataset) lead to memory
problems at some point, given that Rajaram said that sample members spent
two years there in some cases?



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Kit Baum
Gesendet: Montag, 2. November 2009 17:06
An: statalist@hsphsun2.harvard.edu
Betreff: st: re: Creating number of days per month

<.>
It was suggested that the long format makes this easy: to compute how  
many days in each calendar month the patient was in the facility.  
Indeed so:

clear
inp str10(var1 var2)
"30nov2007"   "14feb2008"
"21jan2009"   "07apr2009"
"24apr2008"   "09jul2008"
"22feb2008"   "08may2008"
"01oct2008"   "16dec2008"
"13jul2009"   "28sep2009"
"04oct2008"   "20dec2008"
"07jul2009"   "22sep2009"
"03jun2008"   "19aug2008"
"11feb2009"   "30apr2009"
"31mar2007"   "17jun2007"
"01may2007"   "19jul2007"
"04apr2007"   "22jun2007"
"03jul2008"   "20sep2008"
"10jul2007"   "27sep2007"
end

gen date1=date(var1, "DMY")
gen date2=date(var2, "DMY")
drop var1 var2
g patientid = _n
reshape long date, i(patientid)
tsset patientid date
format date %td
l, sepby(patientid)
tsfill
g mon = mofd(date)
g days = 1
collapse (count) days, by(patientid mon)
format mon %tm
l patientid mon days, sepby(patientid)



Kit Baum   |   Boston College Economics & DIW Berlin   |
http://ideas.repec.org/e/pba1.html
                               An Introduction to Stata Programming   
|   http://www.stata-press.com/books/isp.html
    An Introduction to Modern Econometrics Using Stata  |
http://www.stata-press.com/books/imeus.html

*
*   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   |   What's new   |   Site index