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 destring
command can be used to convert the alfanumerical values into numerical values.
The example below demonstrates how to convert the values of the variable gender
from alfanumerical to numerical. Note: The variable keeps the original name as it is only the value format that is changed.
//Connect to datastore
require no.ssb.fdb:23 as db
create-dataset demography
import db/BEFOLKNING_KJOENN as gender
tabulate gender
destring gender
//Generate descriptive statistics for the numerical gender variable
summarize gender