BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Hello,

 

Using SAS 9.4 

 

Is it possible to compare SAS dates in mmddyy6 format? I have my dates listed as 010119 (mmddyy) format for a specific reason and cannot change them and wanted to know if it is possible to use a where statement in proc freq to keep dates after 010119. 

 

PROC FREQ DATA = HAVE;
TABLES LAST_NAME*LAST_CLINIC_FOLLOW_UP;
WHERE LAST_CLINIC_FOLLOW_UP > 010119;
RUN;

 

However, upon inspecting the data I have dates that are not after this date. Any help would be great, thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Assuming you have SAS dates, yes you can, but you need to specify dates as a date literal in the date9 format. Or use the MDY function.

 

WHERE LAST_CLINIC_FOLLOW_UP > '01Jan2019'd;

WHERE LAST_CLINIC_FOLLOW_UP > mdy(1, 1, 2019);

@GS2 wrote:

Hello,

 

Using SAS 9.4 

 

Is it possible to compare SAS dates in mmddyy6 format? I have my dates listed as 010119 (mmddyy) format for a specific reason and cannot change them and wanted to know if it is possible to use a where statement in proc freq to keep dates after 010119. 

 

PROC FREQ DATA = HAVE;
TABLES LAST_NAME*LAST_CLINIC_FOLLOW_UP;
WHERE LAST_CLINIC_FOLLOW_UP > 010119;
RUN;

 

However, upon inspecting the data I have dates that are not after this date. Any help would be great, thank you!



 

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

Are your SAS dates numeric? 

If yes, are they "just" formatted with some date format?

 

Can you do a proc contents and check plz and let us know? Thanks

GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Yes they are numeric variables

Reeza
Super User

Assuming you have SAS dates, yes you can, but you need to specify dates as a date literal in the date9 format. Or use the MDY function.

 

WHERE LAST_CLINIC_FOLLOW_UP > '01Jan2019'd;

WHERE LAST_CLINIC_FOLLOW_UP > mdy(1, 1, 2019);

@GS2 wrote:

Hello,

 

Using SAS 9.4 

 

Is it possible to compare SAS dates in mmddyy6 format? I have my dates listed as 010119 (mmddyy) format for a specific reason and cannot change them and wanted to know if it is possible to use a where statement in proc freq to keep dates after 010119. 

 

PROC FREQ DATA = HAVE;
TABLES LAST_NAME*LAST_CLINIC_FOLLOW_UP;
WHERE LAST_CLINIC_FOLLOW_UP > 010119;
RUN;

 

However, upon inspecting the data I have dates that are not after this date. Any help would be great, thank you!