Reputation: 1
I have a SAS dataset saty Base1 which has a date column Activity_Date. I want to get the max of the Activity_Date in the SAS dataset. When I checked the frequency of the Activity_Date column values appear as below:
PROC FREQ DATA=Base1; TABLES Activity_Date/ LIST MISSING; RUN;
/*Activity_Date Frequency
02APR2023 5
03APR2023 5
13APR2023 5*/
PROC SQL;
SELECT MAX(Activity_Date) AS Max_ActivityDt FROM Base1; QUIT;
/* Max_ActivityDt 23113*/
I tried changing the format of the date:
DATA Base2; SET Base1; FORMAT Max_ActivityDt e8601dt.; RUN;
This returns the value: 1960-01-01T06:25:13
Upvotes: 0
Views: 385
Reputation: 6378
Your idea to use a format is correct, but e8601dt is a date-time format, not a date format. You can assign a format in the SQL step:
data have ;
Activity_Date=today() ;
run ;
proc sql ;
create table want as
select max(Activity_Date) as Max_ActivityDt format=date9.
from have
;
quit ;
Upvotes: 4