BookmarkSubscribeRSS Feed
VinnyR
Calcite | Level 5

Ho can I convert  2017-09-28 (Numeric, E8601da. format) into a character 8601 format.

 

It seems I just cant ever get the hang on formats and informats. Somebody please help.

4 REPLIES 4
PBsas
Obsidian | Level 7
data want;
format new_date1 yymmdd10.;
date='2017-09-28';
new_date1=input(date,yymmdd10.); /* SAS numberic date format- better approach */
new_date=put(input(date,yymmdd10.),mmddyy10.); /* character format */
run;

Is this what you are looking for? Your question is not clear.

 

ballardw
Super User

It may help to show what you did and why you weren't satisfied with the result.

A common issue is people trying to change an existing variable from numeric to character. SAS doesn't do that.

VinnyR
Calcite | Level 5
Yes. That is true. Whenever, I use put or input I "compress" the variable
in the bracket. That converts the variable into character and character
cannot be converted using a numeric format. My mistake, lesson learnt.
Tom
Super User Tom
Super User

Should be easy.  So you have something like this where your existing variable is an actual date.

data have ;
  date='28SEP2017'd;
  format date e8601da. ;
  put date= comma7. +1 date e8601da. +1 date date9.;
run;

Log

date=21,090  2017-09-28 28SEP2017

And you want to create a new variable that has a string in it that looks like a date.

data want ;
  set have;
  string = put(date,e8601da.);
run;

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 896 views
  • 0 likes
  • 4 in conversation