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.
hi ...
proc sql;
create table want as
select id, max(eff_dt) as eff_dt format=date9.
from have
group by id;
quit;
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;
Ok, how do I format it so it looks like 01jan1990
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.