DATA Step, Macro, Functions and more

INPUT function requires a character argument

Reply
New Contributor
Posts: 3

INPUT function requires a character argument

I am very new to SAS. I usually execute a step for export to excel in a project, and never had a problem, but this time, after this step, I found two errors in relationship with the format.

 

 

Here is the step and the errors:

 

20         proc sql noprint;

21         select put(max(Fh_Llamada), yymmn6.0) as Fhdato

22         into: Fhdato

23         from pivot;

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

ERROR: The following columns were not found in the contributing tables: Fh_Llamada.

 

Would it be possibly that a contributing table is missing? Is not very usual.

Thanks,

Super User
Posts: 9,903

Re: INPUT function requires a character argument

Check the type of variable Fh_Llamada in dataset pivot. It seems to be character.

And the correct community for this question is Base SAS Programming, so I will move it there.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
New Contributor
Posts: 3

Re: INPUT function requires a character argument

Posted in reply to KurtBremser

Thank you for the quick answer. I will try to do it.

PROC Star
Posts: 1,215

Re: INPUT function requires a character argument

running 

 

proc contents data=pivot;
run;

will give you the answer

New Contributor
Posts: 3

Re: INPUT function requires a character argument

Thank you for your help. I will try to do as you advise.

 

regards,

Super User
Super User
Posts: 7,934

Re: INPUT function requires a character argument

The error message is saying that your MAX() aggregate function is returning a character string and not a number.  What types of values are stored in that variable? What type of variable do you want to create? The PUT() function will create a character variable.

 

If they already contain strings in YYYYMM format and you want them in that same format then you can just take the MAX() since strings in that format will sort properpyl.

 

If they are strings that represent a date, but are in another format, like date9 (ddMONyyyy) or mmddyy or ddmmyy then you will want to convert them to an actual date BEFORE taking the max.  Taking the max of string in that format will sort by lexicographical order and not chronologically. So use the INPUT() function with the proper informat will let you make the string into a date.

input(Fh_Llamada,anydtdte32.)

You should probably leave the value as a date and just apply a format to have it print in the form you want.

proc sql noprint;
  select max(input(Fh_Llamada,anydtdte32.)) format = yymmn6.
    into: Fhdato
    from pivot
  ;
quit;
Ask a Question
Discussion stats
  • 5 replies
  • 320 views
  • 0 likes
  • 4 in conversation