Help using Base SAS procedures

character to numeric

Reply
N/A
Posts: 0

character to numeric

Hey, I'm new to SAS and am stuck. The following is part of my coding. Columns Score and Denominator are showing up as character values, while Numerator is showing up as numeric. I realize I have the character symbol in the length statement, but the statement won't run otherwise.

How do I turn Score and Denominator into numeric?

How to I format the percentage so that it's numeric yet still has the % symbol?

data CMS.cms_database_sas;
length Provider_Number $ 8 Hospital_Name $70 Condition $ 29
Measure_Code $ 10 Measure_Name $ 174 Score $ 4 Sample
$ 13 Footnote $ 5;
infile 'CMS_database.csv' dlm=',' dsd missover lrecl=350;
input Provider_Number $ Hospital_Name $ Condition $ Measure_Code
$ Measure_Name $ Score $ Sample $ Footnote $;
Denominator = scan(Sample,1,'');
Numerator = (denominator*((scan(Score,1,'%'))/100));
format numerator 4.
denominator 4.;
run;
proc print data=CMS.cms_database_sas;
var Provider_Number Measure_Code Score Denominator Numerator;
where Score NE ' ';
run;
Super Contributor
Super Contributor
Posts: 3,174

Re: character to numeric

Posted in reply to deleted_user
Your code either must declare the variables as numeric or create a different named variable and my suggestion is to use the INPUT function to assign the new variables (or you can let SAS to the conversion in an assignment statement but I don't recommend that technique).

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 1 reply
  • 116 views
  • 0 likes
  • 2 in conversation