![]() But so far it looks like this is exactly what I want, I was hoping to generate the new variable to get rid of all the non-numerical characteristics and keep all the numerical characteristics. I will test it next Monday then I will let you know. I haven't tried it on my data yet (I am currently using the data at the research center at my university and I can only access the data there due to the data confidentiality issue, and they don't allow us access the internet there). Note: Dataset has changed since last saved.ĪA987654321 987654336 987654321 987654321Hi William, For example, the below formula will multiply numbers by 10 and yield 'Not number' for non-numeric values: IF(ISNUMBER(A2), A210, 'Not number') Check if a range contains any number. ![]() If you do computations with it you will get garbage. counter that has been disguised by value labels. Unfortunately, if you apply -encode- to a variable that should be -destring-ed, Stata will create a variable that is truly dangerous: in displays and listings it looks like a proper numeric variable with the values that were in the original, but it isn't that. If you mistakenly attempt to -destring- a variable that should be -encode-d, you will, as you have found, get an error message about non-numeric characters. When a variable exceeds that limit, -egen, group()- can be used instead, but the results are not labeled. encode- is limited to variable with at most 65,536 distinct values. Such numeric schemes are needed to use those variables in regressions or other analyses. It is primarily used to provide a numeric scheme for representing discrete variables like religion, nationality, income categories (but not income itself), etc. encode- is used to create a variable that counts up from 1 in 1:1 correspondence with the distinct values of the string variable. and you want to change that to a numeric variable whose values are 1, 756.2, 3.1, etc. What does non-numeric mean Information and translations of non-numeric in the most comprehensive dictionary definitions resource on the web. destring- is used when you have a string variable whose content is entirely numeric, its values look like "1", "756.2", "3.1", etc. ![]() If the number of digits to be converted is greater than 7, then you will need to use one of the following: generate long wanted real (substr (thestringvariable,3.)) generate double wanted real (substr (thestringvariable,3. It is important to understand the difference between -destring- and -encode- (or -egen, group()-). will convert the numeric characters to a numeric value. types, the Date data types, the Boolean data types that store only two values (true or. destring- is something completely different, and is not applicable to this kind of variable. The non-numeric data comprises text or string data. Please pay attention to Stata terminology. But there will be a 1:1 correspondence between those original values and the new variable's 1, 2, 3, etc. It will not, however, apply a label to the values, so these variables will be displayed in listings and outputs as 1, 2, 3, etc. This will create a numeric variable that counts up from 1 and is in 1:1 correspondence with distinct values of the string variable. What you want to do is -egen long wanted = group(the_string_variable).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |