Statalist


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

RE: st: type mismatch/format var


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: type mismatch/format var
Date   Sat, 5 Sep 2009 16:44:08 +0100

Note however that the -encode-d variable is most unlikely to be suitable for regression unless you treat it as a factor variable (Stata 10 and earlier: turn it into a set of indicator variables). 

Nick 
[email protected] 

Maarten buis

-destring- is for variables where the values are numbers
which happen to be stored as strings. As A, B, and R 
aren't numbers it will tell you that it won't work.
What you want is -encode-:

*------- begin example --------
clear
input str1 prof
           1
           2
           a
           b
end
list
encode prof, gen(profnum)
list, nolab
*------- end example ----------
( For more on how to use examples I sent to statalist see:
http://www.maartenbuis.nl/stata/exampleFAQ.html )

Cinzia 

> the variable is  "prof "and takes the following values: 
> 0,1,2,3,4,5,6,7,8,9,A,B, R
> 
> I tried to change the format but it does not work out:
>
> destring  prof_1d, replace float
> prof_1d contains nonnumeric characters; no replace


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index