12-29-2017 04:45 AM
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.
12-29-2017 04:50 AM
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.
12-29-2017 09:30 AM
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.
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;