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
proc sql;
create table want as
select input(chardate, yymmdd10.) as wantdate format = MMDDYY10.
from have;
quit;
proc sql;
create table want as
select input(chardate, yymmdd10.) as wantdate format = MMDDYY10.
from have;
quit;
wantdate = input(chardate,yymmdd10.);
format wantdate mmddyy10.;
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
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!
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.