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" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
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: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Ariel Linden,
DrPH
Gesendet: Freitag, 3. April 2009 01:57
An: statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index