BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
anandmgjsa
Fluorite | Level 6

hi,

 

My code is :

Proc sql;

create tale Engager as 

select date, CLNT_BEO_SEG_CDE , count(*) as count

from BEO

where put(ccsid, 25.) ne '  '  and CLNT_BEO_SEG_CDE = 'Engager'

group by date, CLNT_BEO_SEG_CDE

order by count;

quit;

i am getting error : Numeric format f in put function requires a numeric argument.

 

Please help!!

1 ACCEPTED SOLUTION

Accepted Solutions
SASJedi
SAS Super FREQ

This response summarizes the excellent feedback provided by Kurt_Bremser, PaigeMiller, sbxkoenk, and ballardw in previous comments. First, some code to create the input table and demonstrate the original problem:

 

data BEO;
	infile datalines truncover;
	input ccsid:$10. date:mmddyy10. CLNT_BEO_SEG_CDE:$20.;
datalines;
L100 02/21/2022 Lurker
E101 03/10/2022 Engager
D102 04/10/2022 Disengaged
E104 05/12/2022 Engager
E105 05/12/2022 Engager
E106 05/12/2022 Engager
;

proc sql;
create table Engager as 
	select date, CLNT_BEO_SEG_CDE, count(*) as count
		from BEO
		where put(ccsid, 25.) ne ' '  
		  and CLNT_BEO_SEG_CDE = 'Engager'
		group by date, CLNT_BEO_SEG_CDE
		order by count
;
quit;

Log:

 

ERROR: Numeric format F in the PUT function requires a numeric argument.

NOTE: The SAS System stopped processing this step because of errors.

The error message indicates that the PUT function call is trying to apply a numeric format (25.) to a character argument (cssid). When testing for missing values, it’s better to use syntax that doesn’t require you to detect and/or convert argument data types. Your original expression:

where put(ccsid, 25.) ne ' '  

would be better expressed using either the “is not missing” WHERE statement syntax, or using the MISSING function, which works in any expression. Both expressions will produce consistent results for both character and numeric values:

where ccsid is not missing 
where not missing(ccsid) 

You reported getting errors even after eliminating the PUT function, but I could not replicate any condition where the expression still produced an error and you did not provide a copy of the code. This solution, originally supplied by  Kurt_Bremser, runs without error and produces the correct result set:

 

proc sql;
create table Engager as 
	select date, CLNT_BEO_SEG_CDE, count(*) as count
		from BEO
		where ccsid ne ' '  
		  and CLNT_BEO_SEG_CDE = 'Engager'
		group by date, CLNT_BEO_SEG_CDE
		order by count
;
quit;

Log:

 

NOTE: Table WORK.ENGAGER created, with 2 rows and 3 columns.

This proposed alternative solution also ran without error and produced the correct results:

proc sql;
create table Engager as 
   select date, CLNT_BEO_SEG_CDE , count(*) as count
      from BEO
      where not missing(ccsid)
        and CLNT_BEO_SEG_CDE = 'Engager'
      group by date, CLNT_BEO_SEG_CDE
      order by count
;
quit;

Log:

NOTE: Table WORK.ENGAGER created, with 2 rows and 3 columns.

May the SAS be with you!

Mark

Check out my Jedi SAS Tricks for SAS Users

View solution in original post

8 REPLIES 8
sbxkoenk
SAS Super FREQ

Hello,

 

I think the error message is quit clear, no?

'ccsid' is a character variable (character argument).

You get the same error when submitting this:

PROC SQL;
 select *
 from sashelp.class
 where put(name,25.) is not missing;
QUIT;
/* end of program */

ERROR: Numeric format F in PUT function requires a numeric argument.

Koen

anandmgjsa
Fluorite | Level 6

even if i don't use put function, it's giving error.

error is : expression using not equals (^=) has components that are of different data types.

I can not paste the log as it's on VDI and I can not copy/snip from it.

sbxkoenk
SAS Super FREQ

Hello,

It's a mystery to me.

But try to to use:

     is not missing

instead of

     ne ' ' or ne ''

.

<< is not missing >> is agnostic for variable type. Variable can be char or num, doesn't matter then.

Koen

Kurt_Bremser
Super User

See this:

Proc sql;
create tale Engager as 
select date, CLNT_BEO_SEG_CDE , count(*) as count
from BEO
where ccsid ne '  '  and CLNT_BEO_SEG_CDE = 'Engager'
group by date, CLNT_BEO_SEG_CDE
order by count;
quit;

If this still throws a message, look at the variable types as reported by PROC CONTENTS for both ccsid and CLNT_BEO_SEG_CDE.

ballardw
Super User

@anandmgjsa wrote:

even if i don't use put function, it's giving error.

error is : expression using not equals (^=) has components that are of different data types.

I can not paste the log as it's on VDI and I can not copy/snip from it.


When you can't copy and paste then you have to be extra careful what you type. "Create tale Engager" ????

 

I notice that you do not provide the actual code from:

even if i don't use put function, it's giving error.

error is : expression using not equals (^=) has components that are of different data types.

So I suspect you did something that does not compare the NUMERIC value of CCSID properly.

My guess is you used something like

where ccsid ne '  '  and CLNT_BEO_SEG_CDE = 'Engager'

which is the wrong way to compare numeric values as missing because ' ' is not a numeric value.

You could use:

   ccsid ne . and ...

or better (as said by @sbxkoenk )

  not missing(ccsid) and ...

 

Do you have some objection to using PROC CONTENTS to actually examine your variables? We have to guess because you are showing errors and we don't have data or actual descriptions of your variables.

 

PaigeMiller
Diamond | Level 26
put(ccsid,25.)

requires variable CCSID to be numeric (and apparently it is not).

 

To help us all out, from now on please show us the entire LOG of this PROC SQL (including the code, ERRORs, WARNINGs and NOTEs), not just selected parts. Please paste the log into the window that appears when you click on the </> icon, this preserves the formatting of the log and makes it more readable — DO NOT SKIP THIS STEP.

--
Paige Miller
SASJedi
SAS Super FREQ

This response summarizes the excellent feedback provided by Kurt_Bremser, PaigeMiller, sbxkoenk, and ballardw in previous comments. First, some code to create the input table and demonstrate the original problem:

 

data BEO;
	infile datalines truncover;
	input ccsid:$10. date:mmddyy10. CLNT_BEO_SEG_CDE:$20.;
datalines;
L100 02/21/2022 Lurker
E101 03/10/2022 Engager
D102 04/10/2022 Disengaged
E104 05/12/2022 Engager
E105 05/12/2022 Engager
E106 05/12/2022 Engager
;

proc sql;
create table Engager as 
	select date, CLNT_BEO_SEG_CDE, count(*) as count
		from BEO
		where put(ccsid, 25.) ne ' '  
		  and CLNT_BEO_SEG_CDE = 'Engager'
		group by date, CLNT_BEO_SEG_CDE
		order by count
;
quit;

Log:

 

ERROR: Numeric format F in the PUT function requires a numeric argument.

NOTE: The SAS System stopped processing this step because of errors.

The error message indicates that the PUT function call is trying to apply a numeric format (25.) to a character argument (cssid). When testing for missing values, it’s better to use syntax that doesn’t require you to detect and/or convert argument data types. Your original expression:

where put(ccsid, 25.) ne ' '  

would be better expressed using either the “is not missing” WHERE statement syntax, or using the MISSING function, which works in any expression. Both expressions will produce consistent results for both character and numeric values:

where ccsid is not missing 
where not missing(ccsid) 

You reported getting errors even after eliminating the PUT function, but I could not replicate any condition where the expression still produced an error and you did not provide a copy of the code. This solution, originally supplied by  Kurt_Bremser, runs without error and produces the correct result set:

 

proc sql;
create table Engager as 
	select date, CLNT_BEO_SEG_CDE, count(*) as count
		from BEO
		where ccsid ne ' '  
		  and CLNT_BEO_SEG_CDE = 'Engager'
		group by date, CLNT_BEO_SEG_CDE
		order by count
;
quit;

Log:

 

NOTE: Table WORK.ENGAGER created, with 2 rows and 3 columns.

This proposed alternative solution also ran without error and produced the correct results:

proc sql;
create table Engager as 
   select date, CLNT_BEO_SEG_CDE , count(*) as count
      from BEO
      where not missing(ccsid)
        and CLNT_BEO_SEG_CDE = 'Engager'
      group by date, CLNT_BEO_SEG_CDE
      order by count
;
quit;

Log:

NOTE: Table WORK.ENGAGER created, with 2 rows and 3 columns.

May the SAS be with you!

Mark

Check out my Jedi SAS Tricks for SAS Users

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 7626 views
  • 3 likes
  • 6 in conversation