Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • factor-variable and time-series operators not allowed r(101) with stata 15

    Hi,

    I am receiving an error message "factor-variable and time-series operators not allowed r(101);" when I reach the describe line below (I am using stata 15 and these codes used to work on old versions of stata)

    Code:
    sysuse auto
    use All.dta, clear
    gen q_date=yq(year,quarter)
    keep if q_date >= yq(1995,4)
    sort rssd9001 q_date
    xtset rssd9001 q_date, q
    
    global y1list roeavg
    global y2list L.roeavg LConw eqcw lossw sizew revdivw carw costincomew
    global x1list hh economic inflation st lt gap gdpg
    global x2list L2.roeavg L.LConw L.eqcw L.lossw L.sizew L.revdivw L.carw L.costincomew
    global x2listalt L2.roeavg L.LConw L.eqcw L.lossw L.sizew L.revdivw L.carw L.costincomew L3.roeavg L2.LConw L2.eqcw L2.lossw L2.sizew L2.revdivw L2.carw L2.costincomew
    
    describe $y1list $y2list $x1list $x2list
    kindly advise about how to make the codes work again

  • #2
    Well, the mystery is why this ever worked on an earlier version of Stata. It's not only illegal syntax, but it doesn't even make any sense to ask Stata to -describe- things like L.roeavg. -describe- provides information about labeling, formatting, and storage types of variables. Things like L.roeavg are not variables. So Stata is appropriately complaining that you are using disallowed time-series operators.

    I tried this out on both version 15 and version 14.2, and in both versions Stata gives the same error message. I don't have any older versions of Stata available, but I'd be curious to know what version of Stata did accept this.

    Anyway, the only way to get -describe- to work here is to eliminate all the L. L2. L3., etc. operators from those globals. (Of course, if you are using these same globals with other commands where the time-series operators are allowed and are, in fact, needed for the purpose, then changing the globals is not a good idea and you should just list out the variables you want to -describe- in the -describe- command, or create separate macros for them.)

    By the way, using global macros is an inherently unsafe programming practice. They should be reserved for those extremely rare situations where there is no alternative that will get the job done. At least in what you show, there is nothing that wouldn't be done equally well, and more safely, by the use of local macros.

    Comment


    • #3
      the issue is that the program used to work with other variables. it didn't occur to me that using lagged observation is the cause of the problem. thanks for your comment

      Comment

      Working...
      X