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]

Re: st: factor variables may not contain negative values


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: factor variables may not contain negative values
Date   Fri, 16 Aug 2013 13:27:54 +0200

On Fri, Aug 16, 2013 at 12:52 PM, malay biswas wrote:
> Could please tell meas to how stata operates in the following situation.
>
> I have data set containing codes for missing data and other contingencies.
>
> Yes= 1
> No = 2
> Do Not Know = -9 (Minus)
> Still in Progress= -6(Minus)
>
> When conducting interaction with other variables having similar coding
> arrangements, I get stata notification that "factor variables may not
> contain negative values."

Missing values are special values in Stata (and any other program).
They would have to be, because the program needs to know that they
need to be treated differently from observed values. So the fact that
you know that -9 is a code for a missing value does not mean that
Stata knows that to (how could it?). As a consequence, Stata does not
see missing values but negative values, and these are not allowed as
the error message tells you.

Instead the missing values need to be coded as missing values, see
-help missing-. It is possible to give different missing value codes
to the different situations (probably a good idea), i.e. recode -9 to
.a and -6 to .b. You can also assign value labels to these so called
extended missing values (again, probably a good idea). Once you have
done so, there will no longer be negative values in your variable and
factor variables should work as you expect.

-- Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index