Help using Base SAS procedures

format max date

Accepted Solution Solved
Reply
Regular Contributor
Regular Contributor
Posts: 238
Accepted Solution

format max date

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.


Accepted Solutions
Solution
‎06-12-2012 05:39 PM
Valued Guide
Posts: 765

Re: format max date

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


All Replies
Valued Guide
Posts: 765

Re: format max date

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;

Regular Contributor
Regular Contributor
Posts: 238

Re: format max date

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

Solution
‎06-12-2012 05:39 PM
Valued Guide
Posts: 765

Re: format max date

hi ...


proc sql;

create table want as

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

from have

group by id;

quit;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 8640 views
  • 5 likes
  • 2 in conversation