<>
*************
clear*
inp str10 Date Hospitalisations Deaths
01Jan08 1 0
03Jan08 3 0
05Jan08 0 1
07Jan08 0 1
08Jan08 1 0
11Jan08 2 1
12Jan08 3 0
14Jan08 1 0
end
gen mydate = date(Date, "DM20Y")
*gen marker
g marker=1
tsset mydate, daily
tsfill
replace Hospitalisations=0 if marker!=1
replace Deaths=0 if marker!=1
drop marker
drop Date
l, noo
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Martyn Kirk
Gesendet: Dienstag, 31. März 2009 05:56
An: [email protected]
Betreff: st: Help with filling in dates in a dataset
Hi Statalisters,
I have a reasonably simple query and have searched the help and archives
without identifying a solution.
I have count data recorded on different dates over a year. The dataset only
contains records for dates where there were observations. I want to fill in
the series, so I have a dataset that has 0 counts for days with no
obersvations. An example of what I currently have and what I want to end up
with are below.
Current Dataset:
Date Hospitalisations Deaths
1 Jan 08 1 0
3 Jan 08 3 0
5 Jan 08 0 1
7 Jan 08 0 1
8 Jan 08 1 0
11 Jan 08 2 1
12 Jan 08 3 0
14 Jan 08 1 0
Desired Dataset:
Date Hospitalisations Deaths
1 Jan 08 1 0
2 Jan 08 0 0
3 Jan 08 3 0
4 Jan 08 0 0
5 Jan 08 0 1
6 Jan 08 0 0
7 Jan 08 0 1
8 Jan 08 1 0
9 Jan 08 0 0
10 Jan 08 0 0
11 Jan 08 2 1
12 Jan 08 3 0
13 Jan 08 0 0
14 Jan 08 1 0
Is there a simple way of generating these extra records with zero counts?
All help gratefully received.
Regards
Martyn Kirk
The Australian National University
Canberra, Australia
*
* 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/