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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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