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

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1511 views
  • 0 likes
  • 4 in conversation