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,
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.
Thank you for the quick answer. I will try to do it.
running
proc contents data=pivot;
run;
will give you the answer
Thank you for your help. I will try to do as you advise.
regards,
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.