SAS Data Science

Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Viya (Machine Learning), SAS Visual Text Analytics, with point-and-click interfaces or programming
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mlogan
Lapis Lazuli | Level 10

Hi,

 

I have a date1 variable with number (20140220) and I need to convert it to Date9. format (20FEB2014)

 

Any comments highly appreciated

 

 

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Since it is already a number you could convert the value to a SAS date value and apply the DATE9. format to the variable.

data want ;
    set have ;
    date1 = input(put(date1,8.),yymmdd8.);
    format date1 date9. ;
run;

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

One way is to convert the number to a character string and then use the INPUT function to apply a date format:

 

data A;
format d DATE9.;         /* display d as date */
date1 = 20140220;
c = put(date1, 8.);      /* convert to char */
d = input(c, anydtdte.); /* read with "anydate" format */
run;

proc print; run;
Tom
Super User Tom
Super User

Since it is already a number you could convert the value to a SAS date value and apply the DATE9. format to the variable.

data want ;
    set have ;
    date1 = input(put(date1,8.),yymmdd8.);
    format date1 date9. ;
run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 21816 views
  • 2 likes
  • 3 in conversation