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!!

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

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
  • 1638 views
  • 0 likes
  • 3 in conversation