hi there
i pull data from a SQL environment into SAS. There is a date field in the table which changes to a 5 digit numeric value. How can I get the date to display as dd/mm/yyyy?
Apply the DDMMYY10. format.
SAS dates are counts of days, with 1960-01-01 being day zero. That translates to 5-digit integers for most of the dates you will work with.
hi
I see when I do a max on the date it gives the issue.
@Citrine10 wrote:
I see when I do a max on the date it gives the issue.
You have to apply a date format to any variables that might be a date, including the one extracted from the database via PROC SQL and any other date variables you create via a function.
@Citrine10 wrote:
hi
I see when I do a max on the date it gives the issue.
The result of a MAX function is the raw value, SQL does not automatically apply the format of the source variable.
See this:
data have;
input dateval yymmdd10.;
format dateval yymmdd10.;
datalines;
2020-05-02
2020-07-13
;
proc sql;
select max(dateval) as dateval
from have
;
select max(dateval) as dateval format=yymmdd10.
from have
;
quit;
Result:
dateval
--------
22109
dateval
----------
2020-07-13
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.