[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: How to insert new observation?
> I am trying to insert new observations into the existing
> data file. For
> example, the trading days are only weekdays, namely Monday
> through Friday.
> But I also wish to list Sat and Sun in the data file. (So
> only date appears,
> other columns will be blank because of no data.)
> for example:
> 08/01/2001 --Wed
> 08/02/2001 --Thu
> 08/03/2001 --Fri
> 08/05/2001 --Mon
> I wish to have 08/04/2001 and 08/05/2001 appears to be able
> to merge with
> other data sets. How can I do that?
One way is to add them at the end of the data and then -sort-
them into order. But if you are doing this for many such
weekends, that is no fun, and indeed error-prone.
An alternative is to create a data file with all the days you
need and -merge-.
Suppose I want all the days from 1 Jan 1970 to 31 Dec 2004.
. di mdy(1,1,1970)
. di mdy(1,1,2005)
. di 16437 - 3653
I need a data set (a date set)
. set obs 12784
. gen day = _n + 3652
. format day %d
Now -save- and -merge- with the holey data set.
You need to watch for the fencepost problem (being
off by one).
* For searches and help try: