BookmarkSubscribeRSS Feed
Qisheng-Xia
Calcite | Level 5

/* * Specify the libname */

libname walmart '/folders/myfolders/Walmart';

/* 1. Create two datasets data_a and data_b based on slide 4. */

data walmart.data_a;
input order_id order_time MMDDYY10.;
format order_time MMDDYY10.;
cards;
1001 10/5/2017
1002 10/5/2017
1004 10/7/2017
1003 10/6/2017
1005 10/8/2017
;
run;

2 REPLIES 2
PaigeMiller
Diamond | Level 26

SAS dates are stored internally as the number of days since 01JAN1960, so for example 21915 is 01JAN2020. The FORMAT statement allows 21915 to be shown to humans as 01JAN2020, which humans can understand. Humans cannot understand 21915 as a date, although SAS does understand it as a date.

 

Try the code without the FORMAT statement to see what happens.

--
Paige Miller
Kurt_Bremser
Super User

This is not a function, it is the FORMAT Statement 

A format in SAS is used to display values in a certain manner; in your particular case, the format displays the internal value of a SAS date (the count of days starting at 1960-01-01) in a human-readable manner.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 2 replies
  • 581 views
  • 0 likes
  • 3 in conversation