Hi, I have about 190 variables to change from character variable to numeric variable. Since they are questionnaire data, original data in Excel contains text like: 1-not satisfied, 2-likely not satisfied,....,5-very satisfied. I used compress to extract the number only for the health variable and used the traditional way to convert char to num (please see below code). Is there a faster way to do it? data allnew; set all; HealthN = compress(Health, '-', 'A'); newHealthN = input(HealthN,1.0); drop Health HealthN; rename newHealthN = Health; run; The previous person who worked on this project wrote this code: /*extract the numbers from categorical variables- to remove format-change to numeric*/ data allnew; set all; array sect[*] $ Health Health_later SECT_I_5--SECT_I_38 SECT_IV_a--SECT_VIII_13 Sleep_Quality; array newsect[*] Health Health_later SECT_I_5--SECT_I_38 SECT_IV_a--SECT_VIII_13 Sleep_Quality; do i=1 to dim(sect); newsect[i]=input(substr(sect[i],1,1),1.); end; drop i; run; However, log did not say the right thing: Numeric values have been converted to character values at the places given by: (Line):(Column).
... View more