Statalist


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

AW: st: FW: Help with filling in dates in a dataset


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: FW: Help with filling in dates in a dataset
Date   Fri, 3 Apr 2009 13:48:56 +0200

<> 


*************
clear*

*dataset
inp str10 Month		Value
January		0
March		4
April		2
June		3
end

*with a little help from
http://www.stata-journal.com/sjpdf.html?articlenum=pr0013
gen newmonths=.
tokenize `c(Months)'
forvalues i = 1/12 {
replace newmonths=  `i' if Month== "``i''" 
}

tsset newmonths, monthly
tsfill

forvalues i = 1/12 {
replace Month= "``i''" if newmonths== `i' 
}

drop newmonths
l, noo
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Ariel Linden,
DrPH
Gesendet: Freitag, 3. April 2009 01:57
An: [email protected]
Betreff: re: st: FW: Help with filling in dates in a dataset

This is extremely useful code. Is there a way of modifying this code to fill
in data by month as opposed to every day? Maybe it is intuitive enough to
know the difference between daily and monthly values? For example

Before:

Month		Value
January		0
March		4
April		2
June		3

After:
Month		Value
January		0
Feb		.
March		4
April		2
May		.
June		3
 


Ariel




*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index