BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TMiller16
Fluorite | Level 6

I am using EG and PROC SQL to pull the YEAR from a Date field. 

 

So I used:

 

YEAR(Field_Name) AS BID_YEAR

 

did the same thing for MONTH, however I am getting this error:

 

NOTE: Invalid argument to function YEAR. Missing values may be generated.

NOTE: Invalid argument to function MONTH. Missing values may be generated.

 

So, how does this need to be written?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Your date variable is probably a SAS datetime, and not a SAS date. Try YEAR(DATEPART(field_name)) as BID_YEAR;

PG

View solution in original post

4 REPLIES 4
mkeintz
PROC Star
Are you sure that the field has no missing values?
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
TMiller16
Fluorite | Level 6

Yes, it is coming from an access db, and I checked, it is a date field and there are dates in the tbl.  I even went back to make sure I was using the correct syntax and I am

 

MONTH(BD.BID_DATE) AS BID_MONTH

 

So I am at a loss...

PGStats
Opal | Level 21

Your date variable is probably a SAS datetime, and not a SAS date. Try YEAR(DATEPART(field_name)) as BID_YEAR;

PG
TMiller16
Fluorite | Level 6

As I was thinking about it, I had to do that for another calculation, so that was the issue!  Thank you!!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 32019 views
  • 1 like
  • 3 in conversation