Converting from alfanumerical (text format) to numerical value format
A number of variables use alfanumerical value format (text format). In these cases the values need to be designated with single quotation marks, f.x. ‘1’, ‘2’. The commando
destring can be used to convert the alfanumerical values into numerical values.
The example below demonstrates how to convert the values of the variable
kjønn (gender) from alfanumerical to numerical. Note: The variable keeps the original name as it is only the value format that is changed.
Note also that all values need to contain numerical characters only, in order for the convertion to be successful, unless the options
ignore() are used. The first will force the convertion to go through anyways, but will assign a missing value to values containing non-numerical characters. The second option can be used to specify which characters to be ignored, f.x. commas, dots, hyphens.
create-dataset demografidata import BEFOLKNING_KJOENN as kjønn destring kjønn //Produce simple statistics for the numerical variable summarize kjønn