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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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