BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RAVI2000
Lapis Lazuli | Level 10

Hello everyone,

my date format is 2012-11-06 00:00:00


data sj.have;
length date $21.;
date = "2012-11-06 00:00:00";
run;

 I want just the date from that string in  mm/dd/yyyy (for eg: 03/15/1979) format.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star
data _null_;
  datetime = "2012-11-06 00:00:00";
  format date date9.;
  date = input(substr(datetime,1, 10), yymmdd10.);
  put _all_;
run;

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star
data _null_;
  datetime = "2012-11-06 00:00:00";
  format date date9.;
  date = input(substr(datetime,1, 10), yymmdd10.);
  put _all_;
run;
Kurt_Bremser
Super User

Create a date variable, and apply the fitting format:

data sj.have;
length
  date $21
  num_date 4
;
date = "2012-11-06 00:00:00";
num_date = input(scan(date,1),yymmdd10.);
format num_date mmddyy10.;
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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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