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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 528 views
  • 0 likes
  • 2 in conversation