BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Thalitacosta
Obsidian | Level 7
I have two date variables that I need to format: - the variable "dt" has the "DDMMYY10." format; and - the variable "dt_current" has the "E8601DT26.6" format. When I do the code below, the variable "dt_current" returns missing. What format should I use? proc sql; create table NV2 as select DT format=monyy5., DT_CURRENT format=monyy5. from NV1; quit;
1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

Hello,

 

as "E8601DT26.6" is a date-time format (date + time) you need to extract the datepart from DT_CURRENT in order to be able to successfully use the monyy5. format :

 

datepart(DT_CURRENT) format=monyy5.

 

Koen

View solution in original post

2 REPLIES 2
sbxkoenk
SAS Super FREQ

Hello,

 

as "E8601DT26.6" is a date-time format (date + time) you need to extract the datepart from DT_CURRENT in order to be able to successfully use the monyy5. format :

 

datepart(DT_CURRENT) format=monyy5.

 

Koen

Tom
Super User Tom
Super User

Looks like you have only one DATE variable. The other one is a DATETIME variable.  Date values are stored as number of days. Datetime values are stored as number of seconds.  So you cannot use the same format to display both of them.  But you could use the DTMONYY5. format to display the datetime value in the same MONYY style.

 

PS Why are you displaying only two of the four digits of the year?  That can cause confusion about which century the values represent.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 417 views
  • 1 like
  • 3 in conversation