New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
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-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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