BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
serrld113
Obsidian | Level 7

Hey all,

 

I have this:

 

data have;
input chardate $ 1-10;
datalines;
2017-10-30
2019-01-12
2011-08-01
;
run;

and want my dates to look like this:

10/30/2017

12/01/2019

08/01/2011

 

I tried this:

 

input(compress(chardate,'-'), 8.) as wantdate format = MMDDYY10.

because I saw somewhere that you have to change it to num. but when I run this piece of code in a proc sql all I get is *******.

 

Thanks for the help

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
proc sql;
   create table want as
   select input(chardate, yymmdd10.) as wantdate format = MMDDYY10.
   from have;
quit;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20
proc sql;
   create table want as
   select input(chardate, yymmdd10.) as wantdate format = MMDDYY10.
   from have;
quit;
Tom
Super User Tom
Super User

If you take a number like 20,171,030 are ask SAS to format it as a date you are asking for the date that 20 million days after start of 1960.

It would take 5 digits for the just the year part to display that. SAS formats cannot handle dates that far into the future.

522   data _null_;
523     days=20171030;
524     years=int(days/365.25);
525     year=1960+years;
526     put (years year) (=comma10.);
527   run;

years=55,225 year=57,185

 

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