Dear SAS experts,
Is it possible to achieve this result
without tranwrd (without removing 'UN' or other letters)? I need to have a dynamic code.
I started to solve on this way, but it didn't work yet. Thanks in advance.
data task_1;
input date: $9. ;
day=substr(date,1,2);
month=substr(date,3,3);
year=substr(date,6,4);
if (day) then day1=day;
if (year) then year1=year;
month1=put(month,3.);
if (month) then month1=month;
newdate=cats(year1,month1,day1);
datalines;
27APR2001
30JUL1979
unfeb2005
UNUNK1964
ununkunk
;
Please do not make use of dubious links. Post code, logs, and expected results directly here.
Use the "little running man" for code, </> for logs and textual data (or output), and the camera button for posting screenshots.
data task_1;
input date: $9. ;
length d m y $4 dateStr $10;
day=input(substr(date,1,2), ?? best.);
if day > 0 then d = put(day, z2.0);
month=whichc(upcase(substr(date,3,3)),
"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
if month > 0 then m = put(month, z2.);
year=input(substr(date,6,4), ?? best.);
if year > 0 then y = put(year, z4.0);
dateStr = catx("-", y, m, d);
datalines;
27APR2001
30JUL1979
unfeb2005
UNUNK1964
ununkunk
;
Thanks a lot.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.