SAS : Converting Number Format to Date Format

This tutorial focuses on converting a number format variable to a date format variable.
Convert Number Format to Date Format
Suppose you have a numeric variable that contains dates. You are asked to convert it to SAS date format. It seems to be a easy task but it sometimes becomes a daunting task when you don't know how SAS treats dates. The input data is shown below -
Raw Date Values
Sample Data

The following program is used to create a sample data.
data temp;
input date;
data temp2;
set temp;
newdate = input(put(date,8.),yymmdd8.);
format newdate date10.;
proc print noobs;

  1. PUT Function is used to convert the numeric variable to character format.
  2. INPUT Function is used to convert the character variable to sas date format
  3. FORMAT Function is used to display the SAS date values in a particular SAS date format. If we would not use format function, SAS would display the date in SAS datevalues format. For example, 20588 is a sas datevalue and it is equivalent to '14MAY2016'.

SAS Tutorials : 100 Free SAS Tutorials

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

0 Response to "SAS : Converting Number Format to Date Format"

Post a Comment

Next → ← Prev