PROC EXPAND and SAS® Dates    

Below is a collection of SAS® papers on Proc Expand and SAS® Dates.  

See also SAS Functions/Informats/Formats to convert between character and numeric date versions and ODS Stat Graphs for timelines.  For creating new datasets based on overlap date records, see also Proc SQL.  See Truncating vs round SAS Time values blog.

 

Variable Type

 

Description 

 

Example Format

 

 Example Value

 

Stored Value

 

 

Date

 


# of days from January 1, 1960

DATE9.

YYMMDD10.

Convert from CHAR to NUM

INPUT(DTC, YYMMDD10.)

 01JAN1960

1960-01-01


 

0

 

Time

 

# of seconds

 

 TIME8.

TIME5.

HH:MM:SS 

00:00:00

00:00

as military time so am/pm is not needed

 

0

 

DateTime

 
# of seconds from midnight January 1, 1960

 DATETIME16.

Convert from CHAR to NUM

INPUT(DTC, DATETIME16.)

 

01JAN1960:00:00:00

 

0




Example of SAS® Date Constant (date9. format): '01JAN1960'D

Example of SAS® Time Constant (time5. format): '12:47'T

Example of SAS® DateTime Constant '01JAN1960:12:47'DT

data _null_;

 a='02jan1960'd; * a=1;

 b='12;15't; * b=44100;

 c='02jan1960:12:15'dt; * c=130500;

run;

data _null_;  

 start = '01jan2010'd;  end = '30jun2010'd;  

 days1 = end - start;

 days2 = intck('day', start, end);  

 weeks = intck('WEEK', start, end);

 months = intck('month', start, end);  

 year = intck('year', start, end);

 put days1= days2= weeks= months= year=; 

 run; 

days1=180 days2=180 weeks=26 months=5 year=0

______________________________________________

Beginner Paper A Beginners Guide to SAS Date and Time Handling, Wayne Finley

SAS® Dates: Facts, Formats, and Functions, Debbie Buck [Common Formats]

How to Read, Write, and Manipulate SAS® Dates, Jenine Milum [HOW]

Advanced Paper Why the Bell Tolls 108 Times?  Stepping Through Time with SAS, Peter Eberhardt, Yunbo Sun

______________________________________________

SAS® Date Informats Have a Strange Date? Create your own INFORMAT to Deal with Her, Venky Charkravarthy

SAS® Date Reference Date Intervals, Formats and Functions

SAS Date and Time Intervals, INTCK() Time Difference Blog

SAS® Reference PROC EXPAND Syntax and Functional Summary

______________________________________________

1. Looking for a Date?  A Tutorial on Using SAS Dates and Times, Arthur L. Carpenter [INTNX]

2. The Essentials of SAS Dates and Times, Derek Morgan

3. Working With SAS® Date and Time Functions, Andrew H. Karp

4. Fun with SAS® Date/Time Formats and Informats, Randall Reilly

5. Working with Dates in SAS Software, Christine Smiley

6. Blind Dates and Other Lapses of Reason: Handling Dates in SAS, Alan Dickson

7. It’s Five O’Clock Somewhere!!! Handling Dates And Times In SAS®, Toby Dunn, Sarah Woodruff

8. Why the Bell Tolls 108 times? Stepping Through Time with SAS, Peter Eberhardt

9. Programming with SAS Functions with a Special Emphasis on SAS Dates and Times, Ann Doty

10. Don’t Let a Bad Date Ruin Your Day: Dealing with Invalid Dates in SAS, Lucheng Shao [Invalid argument, input(cDate, ?? ddmmyy10.);]

11. Times Can Be Tough: Taming DATE, TIME and DATETIME Variables, Sajeet Pavate

12. Improve Your Dating: The INTNX Function Alignment Value SAMEDAY, Bruce Gilsen

13. Managing the INTNX Function, Ian Whitlock

14. Partial Dates; decisions and implications of handling partially missing dates, Rachel Bowman

15. Systematic Inductive Method for Imputing Partial Missing Dates in Clinical Trials, Ping Liu

16. Identifying an Event within a Sequence of Events, Marge Scerbo

17. Constructing Begin-End Date Intervals from Event or As-of Dates in a SAS® DATA Step, Thomas Billings

18. Standard SAS Macros for Standard Date/Time Processing, Qin Lin, Tim Kelly

19. When “Anydate” Doesn’t Mean Any Date: A Macro Solution, Charlotte King, John Fleming

20. Checking Out Your Dates with SAS, Christopher Bost

21. So Many Date Formats: Which Should You Use?

22. Using SAS® Dates and Times – A Tutorial, Jonas Bilenas

23. Create a Unique Datetime Stamp for Filenames or Many Other Purposes Joe DeShon

24. THE SECRET TO SAS DATES, Alison Little

25. Adjusting Dates in a New Century, Malachy Foley [YEARCUTOFF]

26. DATE HANDLING IN THE SAS SYSTEM, Bruce Gilsen

27. Avoiding Blind Dates with SAS, Derek Morgan


1. Playing Favorites: How to Manage Date Conflicts When Some Date Ranges are Preferred Over Others, Eric Wong

2. A proposal for intervention and event partial date time imputation, Chunpeng Zhao [Presentation]

3. Combining Multiple Date-Ranged Historical Data Sets with Dissimilar Date Ranges into a Single Change History Data Set, Jim Moon

4. Measuring Medication Adherence with Simple Drug Use and Medication Switching, Stacy Wang, Zhongwen Huang, Seth Traubenberg

5. Starts and Stops: Processing Episode Data With Beginning and Ending Dates, Mike Rhoads

6. SPAN SPAN AWAY! Creating One Unique Record for Overlapping Admissions and Discharges from Multiple Inpatient Hospital Stays, Shabnam Mehra, Robyn Spittle, Becky Larsen, Diane Haynes, Kathy Dailey

7. Fast Solution for Identifying and Quantifying Gaps in Messy Time Segments, Lorne Salter [Proc SQL]

8. Overlapping Date Segments: How to Clean up the Mess, Doug Shannon, Wade Bannister

9. Chaining Logic in One Data Step, Libing Shi, Ginny Rego [Macro]

10. Hip Hip ARRAY…Expanding and Modifying Records With an ARRAY Jeanina Worden, Lauren Shinaberry

11. Finding and Generalizing a "Best Before" Date Marje Fecht

12. Pretty Dates All in a Row, Dianne Louise Rhodes

13. Getting the Right DATES (with SAS), Marje Fecht [End of the Month Day]

14. Handling Dates in the Macro Facility, Toby Dunn

15. No More Bad Dates!: A Guide to SAS Dates in Macro Language, Kate Burnett-Isaacs, Andrew Clapson

16. Tips to Manipulate the Partial Dates, Deli Wang and Chunxia Lin

17. Bad Date: How to find true love with Partial Dates! amrata Pokhrel [Macro]

18. A Conceptual Strategy and Macro Approach for Partial Date Handling in Data De-Identification, Kelsey Reppert, Amy Caison [Macro]

19. Finding Time: SAS® and Data Warehouse Solutions for Determining Last Day of the Month, Jennifer O’Neil, Laural Wierenga [Macro]

20. Generating Dates Automatically, Armando Fabia

21. Time Is on Your Side. Yes It Is. Using Base SAS to Manipulate Time, Carole Jesse

Powered by Wild Apricot Membership Software