DATA Step, Macro, Functions and more

Numeric Format Error

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

Numeric Format Error

Proc SQL;
Create table Results.VarResultsCL as
SELECT
 AppVintage format = $CHAR24.
,Strategy format = $CHAR24.
,Approval_Rate_Diff format = percent12.2
,Activation_Rate_Diff format = percent12.2
FROM Portrevw.awm_aa_variance_cl;
quit;

I am using that code to create a SAS data set. However, when I run it, I get this error:

ERROR: Numeric expression requires a numeric format.

 

The format from the SQL table for AppVintage is datetime, null

The format for approval_Rate_Diff and activation_rate_diff is decimal(5,4),null

 

Can anyone help?

 

Thanks!

a


Accepted Solutions
Solution
‎12-01-2017 04:19 PM
Super User
Posts: 13,321

Re: Numeric Format Error

Posted in reply to awmeyertimmy

If your AppVintage is a datetime then the value is numeric and so you cannot assign $char format. You likely would want something like DATETIME20. (or a larger number if you need to see decimal second values).

 

If your Strategy variable is actually numeric you would have the same error.

View solution in original post


All Replies
Solution
‎12-01-2017 04:19 PM
Super User
Posts: 13,321

Re: Numeric Format Error

Posted in reply to awmeyertimmy

If your AppVintage is a datetime then the value is numeric and so you cannot assign $char format. You likely would want something like DATETIME20. (or a larger number if you need to see decimal second values).

 

If your Strategy variable is actually numeric you would have the same error.

Occasional Contributor
Posts: 15

Re: Numeric Format Error

Works great! Thanks!

Valued Guide
Posts: 559

Re: Numeric Format Error

Posted in reply to awmeyertimmy

Hi,

 

Most cases DBMS have datetime even there is no time(0's), if this is your case or if you don't need the time and need only the date then use DATEPART() function.

DATEPART(AppVintage) format=DATE9. as Appvintage

Thanks,
Suryakiran
Super User
Super User
Posts: 7,934

Re: Numeric Format Error

Posted in reply to awmeyertimmy

Why attach any formats?  Why not just use the formats that SAS figures out from looking into the external database?

proc sql;
create table Results.VarResultsCL as
  select
   AppVintage
  ,Strategy
  ,Approval_Rate_Diff
  ,Activation_Rate_Diff
  from Portrevw.awm_aa_variance_cl
;
quit;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 333 views
  • 2 likes
  • 4 in conversation