Statalist


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

RE: st: type mismatch/format var


From   Maarten buis <[email protected]>
To   stata list <[email protected]>
Subject   RE: st: type mismatch/format var
Date   Sat, 5 Sep 2009 08:33:31 +0000 (GMT)

> 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

-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 )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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