Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: RE: Re: RE: may not use time-series operators on string variables

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: Re: RE: may not use time-series operators on string variables
Date   Thu, 4 Jul 2002 09:55:57 +0100

Lee Chuntao's original question:
>    In my dataset there is a variable v1, which is a string
> variable. I try to use l.v1, after i set the time variable (eg,
> tsset time). I don't know why stata do not permit timeseries
> operators on string variables, it seems not reasonable for the
> lag or lead operators, beyond the difference operators
> i wonder if there is some sort way so that i can use the laged
> string variable?
> Yes. -destring- your string variable first. Stata quite reasonably
> wants you to have your variables with numeric meaning held
> as numeric.

< various answers yesterday >

Yet another answer: -encode- the variable first.

Another side to this: suppose Stata did allow string variables
to take time series operators. This would create a new class of pitfall,
as far as users are concerned, namely, a numeric variable which has
been input mistakenly as string is -tsset- but the user then, some distance
downstream, tries to use that variable as if it were numeric. Not
much damage would be done, beyond the need to puzzle this out, but
this is not that far-fetched, for reasons discussed at

In short, there would be a user downside for being permissive
about what can take time series operators.

[email protected]

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index