Statalist


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

st: R: type mismatch/format var


From   "Carlo Lazzaro" <carlo.lazzaro@tin.it>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: R: type mismatch/format var
Date   Sat, 5 Sep 2009 10:26:54 +0200

Dear Cinzia,

if you're interested in replacing letters with numbers, please
try: 

replace  prof_1d="10" if  prof_1d=="A".

HTH and Kind Regards,
Carlo

-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Cinzia Rienzo
Inviato: sabato 5 settembre 2009 9.50
A: statalist@hsphsun2.harvard.edu
Oggetto: st: type mismatch/format var

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/


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