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

I have a char date that is formatted mm/dd/yyyy, I need to keep the date in a char format and change it to be a mm/dd/yy. Any assistance is appreciated.   Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

data want;
set have;
want=cats(substr(char_date,1,6),substr(char_date,9));
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

You can do something like this

 

data test;
   chardate='03/04/2019';
   newchardate=put(input(chardate, mmddyy10.), mmddyy8.);
run;
novinosrin
Tourmaline | Level 20

data have;
do date=today()-7 to today();
char_date=put(date,mmddyy10.);
output;
end;
drop date;
run;

data want;
set have;
substr(char_date,7,2)=' ';
char_date=compress(char_date);
run;
novinosrin
Tourmaline | Level 20

data want;
set have;
want=cats(substr(char_date,1,6),substr(char_date,9));
run;
ScotchCat
Obsidian | Level 7

Perfect! Thanks so much!!

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch Now →
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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