In my Dataset I have 12241 unique values, every individual is represented by the variable codind (it can appear in several lines) which is a string variable and I would like to have it as a numeric variable such that the first individual is called 1, the second one 2 until the last one called 12241. Here I add an example of the Dataset, in this case the first individual is 10001T0QF100100 and the second one 10002E0QF380100:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str15 codind "10001T0QF100100" "10001T0QF100100" "10001T0QF100100" "10001T0QF100100" "10001T0QF100100" "10001T0QF100100" "10001T0QF100100" "10001T0QF100100" "10001T0QF100100" "10001T0QF100100" "10001T0QF100100" "10002E0QF380100" "10002E0QF380100" "10002E0QF380100" "10002E0QF380100" "10002E0QF380100" "10002E0QF380100" "10002E0QF380100" "10002E0QF380100" "10002E0QF380100" "10002E0QF380100" end
Pablo
0 Response to How to attribute a numeric value to a string variable through a loop
Post a Comment