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.

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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