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

I am trying to format a max query for the date. My code is:

proc sql;

create table lib.market as

(select distinct

id,

max(eff_dt) as eff_dt

from lib.cleaning

group by id);

run;

The table has in it:

id           eff_dt

111        1/1/1990

111        1/1/1991

111        1/12/1991

111        1/15/2010

222        1/1/1991

222        1/1/1993

222        1/1/2011

It returns the following:

id            eff_dt

111         -21914

222         13419

How do I make it appear with the dates. I am sure it is some format but not sure.

1 ACCEPTED SOLUTION

Accepted Solutions
MikeZdeb
Rhodochrosite | Level 12

hi ...


proc sql;

create table want as

select id, max(eff_dt) as eff_dt format=date9.

from have

group by id;

quit;

View solution in original post

3 REPLIES 3
MikeZdeb
Rhodochrosite | Level 12

hi ... fyi ...

1/ you can get rid of the parentheses

2/ SQL ends with a QUIT

3/ you are grouping by ID so you can get rid of DISTINCT

proc sql;

create table want as

select id, max(eff_dt) as eff_dt format=mmddyy10.

from have

group by id;

quit;

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

Ok, how do I format it so it looks like 01jan1990

MikeZdeb
Rhodochrosite | Level 12

hi ...


proc sql;

create table want as

select id, max(eff_dt) as eff_dt format=date9.

from have

group by id;

quit;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 33587 views
  • 5 likes
  • 2 in conversation