Monday, February 4, 2008

SAS: Numeric conversion of variables containing special characters and alphabets


  1. Sometimes, a programmer have to convert few lab results (variable: which are in character) to numeric form.
  2. These variables may contain numbers(123456789.) as well as special characters(*/()*&%$,:'+-<>") and alphabets.
  3. In such case, the following code does the numeric conversion of that variable:

if indexc(result,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz*/()*&%$,:'+-<>") = 0 and result ne " " then do;

numericresult=input(result,best.);

end;

No comments:

Post a Comment