BookmarkSubscribeRSS Feed
juliehn
Fluorite | Level 6

Hi all,

 

I need to create to date variables with the following formate: date1=dd/mm/yy and date2=dd/mm/yy.

 

I have the following program and it doesn't work:

 

data example;

set dataset;

 

date1='01jan18'd;

date2='31dec18'd;

 

put date1 ddmmyy8.;

put date2 ddmmyy8.;

 

run;

 

The dates return in weird formats.

 

Hope someone can help!

 

Best,

Julie

 

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

Hi. In the code you posted you only format the date variables in the date values you put to the log. The date variables in the data set will not be formatted. Use a Format Statement like this

 

data test;
   date1='01jan18'd;
   date2='31dec18'd;
   format date1 date2 ddmmyy8.;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1 reply
  • 695 views
  • 0 likes
  • 2 in conversation