Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: RE: egen with error after set obs erases obs


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: egen with error after set obs erases obs
Date   Tue, 8 Feb 2011 15:25:47 +0000

Not so, but it's not a very short story. 

First, your -egen- call is illegal. -from(1) to(5) block(14)- are all options. It is true that the error message is a little cryptic. But at the point of complaint Stata is prepared to see stuff matching  

syntax [if] [in] [, *]

whereas it sees 

from(1) to(5) block(14)

That does not match the syntax. In the absence of a comma, Stata chokes on the first token, namely "from", and interprets it as a illegal attempt to specify a varlist. Whether or not you have such a variable, such syntax is illegal, and you get thrown out of -egen- early on. 

You just need to specify the comma. 

Now in terms of your claim: You never had any data to erase. 

You started with no data, and -egen- never created the variable you asked; it didn't get that far. 

-set obs #- does not itself create observations when there are as no yet no variables; it is just a declaration of intent on your part acknowledged by Stata. The logic is simple: -set obs #- starting from scratch could not create observations because it would not know which variables to fill. 

Nick 
n.j.cox@durham.ac.uk 

Airey, David C

I noticed these commands

. set obs 70
obs was 0, now 70

. egen cell = seq() from(1) to(5) block(14)
varlist not allowed
r(101);

result in 0 observations on my Stata 11 copy for the Mac. After the egen error, I should still have 70 observations. After doing this I have to set obs 70 again before proceeding.

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index