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-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
  • 4 replies
  • 29399 views
  • 0 likes
  • 3 in conversation