Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72787

r(109) type mismatch - recode string values in numeric values

$
0
0
Hello everyone,

I am trying to generate a dummy for campany size from a variable that includes the number of employees of the year 2012. Some companies did not state their numbers. The value of this case is n.v.. I do not want to delete this values as I can add values of other years later on.

Data looks like that:

company_id numberemployees_2012
19765 1000
87644 n.v.
77931 25

Code:
encode numberofemployees2012, gen(number_employees2012_n)

generate number_emp_large_2012 = 1
replace number_emp_large_2012 = 0 if (number_employees2012_n <= 250 | number_employees2012_n=="n.v.")

this gives an error message r109 "type mismatch"

As a solution I am trying to recode the "n.v." values of numberofemployees_2012_n from string to numeric values (=0). But I don't know how to do that. I read in another post about replacing n.v. using label value?

Thank you for your help!


Viewing all articles
Browse latest Browse all 72787

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>