BookmarkSubscribeRSS Feed
JC79
Calcite | Level 5

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,

5 REPLIES 5
Kurt_Bremser
Super User

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.

JC79
Calcite | Level 5

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

PeterClemmensen
Tourmaline | Level 20

running 

 

proc contents data=pivot;
run;

will give you the answer

JC79
Calcite | Level 5

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

 

regards,

Tom
Super User Tom
Super User

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2587 views
  • 0 likes
  • 4 in conversation