Statalist


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

st: type mismatch/format var


From   Cinzia Rienzo <[email protected]>
To   [email protected]
Subject   st: type mismatch/format var
Date   Sat, 5 Sep 2009 08:50:29 +0100 (BST)

Dear all,

I have a problem with a variable.

the variable is  "prof "and takes the following values: 
0,1,2,3,4,5,6,7,8,9,A,B, R

i get a type mismatch if i do the following:  

 sum lwage if  prof_1d==1
type mismatch


but it allows me the sum if i write :

 sum lwage if  prof_1d=="1"

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       lwage |     18608    1.564116    .5385916  -2.387844   5.754426

The format of the variable is:

  variable name  display format
  -----------------------------
  prof_1d        %1s


I tried to change the format but it does not work out:

destring  prof_1d, replace float
prof_1d contains nonnumeric characters; no replace


I also tried to replace letter in numbers:
replace  prof_1d=10 if  prof_1d=="A"
type mismatch
r(109);

. replace  prof_1d=10 if  prof_1d==A
A not found

How can i deal with this considering that i need the variable in a 
regression?

I appreciate any help,

Thanks you all in advance,

Cinzia


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