## date9. format

Solved
Frequent Contributor
Posts: 126

# date9. format

I have the following code and I need to have variable d in date9. format. Why is is that d resolves to 04Jun2511? I would expect it to (and need it to) resolve to some date in Mar2014.

%let yyyymm=201403;

data test;

d=&yyyymm;

format d date9.;

run;

Accepted Solutions
Solution
‎07-17-2014 12:50 PM
Super User
Posts: 13,531

## Re: date9. format

The value is being resolved as the number 201403 with when the Display Format date9, , as do all date formats, treat as the number of days since 1 Jan 1960 as day 0. 200,000 plus days translates to over 540 years.

try

%let yyyymm=201403;

data test;

D= input("&yyyymm", yymmn6.); /* to apply an INFORMAT to read the value as a date expressed as year and month*/

format d date9.;

run;

All Replies
Solution
‎07-17-2014 12:50 PM
Super User
Posts: 13,531

## Re: date9. format

The value is being resolved as the number 201403 with when the Display Format date9, , as do all date formats, treat as the number of days since 1 Jan 1960 as day 0. 200,000 plus days translates to over 540 years.

try

%let yyyymm=201403;

data test;

D= input("&yyyymm", yymmn6.); /* to apply an INFORMAT to read the value as a date expressed as year and month*/

format d date9.;

run;

Posts: 1,270

## Re: date9. format

201403 is just a number for SAS. Try this to get a date within March

%let yyyymm=201403;

data test;

d=input(put(&yyyymm,\$6.),yymmn6.);

format d date9.;

run;

🔒 This topic is solved and locked.