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

I have a volatile table built wilh a set of values
ID           XDATE

123        02APR2020

234        06FEB2020

234        03MAR2020
.....

I am querying the Max date grouped by the ID
PROC SQL;
select ID, MAX(XDATE) as XDATE from TABLE1
group by ID;
run;

I get the result as 
ID         XDATE
123      22007
234      22046
345      21970

How do i get a date output like '12-31-2999'

1 ACCEPTED SOLUTION

Accepted Solutions
smantha
Lapis Lazuli | Level 10

PROC SQL;
select ID, MAX(XDATE) as XDATE format=mmddyy10. from TABLE1
group by ID;
run;

View solution in original post

4 REPLIES 4
smantha
Lapis Lazuli | Level 10

PROC SQL;
select ID, MAX(XDATE) as XDATE format=mmddyy10. from TABLE1
group by ID;
run;

Jyuen204
Obsidian | Level 7

Thank you Thank you!

mklangley
Lapis Lazuli | Level 10

MAX(XDATE) as XDATE format mmddyyd10.

ballardw
Super User

In SQL when you use a function with AS NEWVARIABLE then the result will use the default numeric format, which is BEST because you did not tell SAS you wanted a different one.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1112 views
  • 0 likes
  • 4 in conversation