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-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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