AETRT = 22459
How I can it compare with this ?
AESTDTC = 2021-07-05
Your question is not clear. Though I'd recommend to look at this SAS Date format.
Here is how you can check formatted date values:
data test;
format AETRT_Formatted yymmdd10.;
AETRT = 22459 ;
AETRT_Formatted = AETRT;
run;
You can also use PUT function if this is something you want to achieve:
AETRT_Formatted=put(AETRT,yymmdd10.);
@lovecoding wrote:
AETRT = 22459
How I can it compare with this ?AESTDTC = 2021-07-05
Is AETRT numeric or character? Is AESTDTC really a character variable, or is it numeric with a format? Please check PROC CONTENTS and determine if each of these variables is numeric or character. Let us know.
To understand more about dates and times in SAS you can read:
For a way to compare see the following code:
data _null_;
date1 = 22459;
date2 = mdy(5, 7, 2021);
days_between_1_2 = intck('day', date1, date2);
days_between_2_1 = intck('day', date2, date1);
formatted_date1 = date1;
formatted_date2 = date2;
format formatted_date1 formatted_date2 date9.;
put date1= '|' formatted_date1= /
date2= '|' formatted_date2= /
'days_between date1 and date2 is ' days_between_1_2 /
'days_between date2 and date1 is ' days_between_2_1;
run;
@lovecoding wrote:
AETRT = 22459
How I can it compare with this ?AESTDTC = 2021-07-05
Assuming that the variable whose name ends with the letter C is a CHARACTER variable you can convert its contents to a date value using the INPUT() function. Looks like the string is in a style that the YYMMDD informat can read.
To have the numeric value print in the same style attach the YYMMDD format to the it.
data want;
set have;
difference = aetrt - input(aestdtc,yymmdd10.);
format aetrt yymmdd10.;
run;
Result
Obs AETRT AESTDTC difference 1 2021-06-28 2021-07-05 -7
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.