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;
... View more