Dear Statlist community,
I faced a strange issue working with the following dataset when I changed a string variable to numeric and wanted to create a new variable by dividing: let's look at my codes and data below. The problem is that my new variable (visit_ratio) is simply wrong, where in fact, it should be a simple arithmetic. Any help would be appreciated.
and here is the data:
The visit ratio should be in decimal format, and I got confused why I cannot obtain the right results. Thanks.
I faced a strange issue working with the following dataset when I changed a string variable to numeric and wanted to create a new variable by dividing: let's look at my codes and data below. The problem is that my new variable (visit_ratio) is simply wrong, where in fact, it should be a simple arithmetic. Any help would be appreciated.
Code:
*count number of observation per year and state bysort year state_name : gen visit = _n *create a numerical value for number of physican encode Number_of_Active_Physicians, gen(num_phy) *create a ratio gen visit_ratio = visit/num_phy
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int year str20 state_name str27 Number_of_Active_Physicians 2000 "alaska" "1,764" 2013 "alaska" "1,764" 2013 "alaska" "1,764" 2014 "alaska" "1,764" 2014 "alaska" "1,764" 2014 "alaska" "1,764" 2014 "alaska" "1,764" 2015 "alaska" "1,764" 2017 "alaska" "1,764" 2017 "alaska" "1,764" end
Comment