SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 33305 views
  • 1 like
  • 3 in conversation