I want to convert the datereturned field from text to number type ( to mmddyy10. Format). It has length $ 10. and format $10.I have tried the below SAS code and it doesn’t work.
Still it display as Text instead of number and values shows as .
data want;
set have;
length _ datereturned $10.;
_datereturned =input(datereturned,mmddyy10.);
put _datereturned = date9.;
run;
Thanks in Advance
It's the missing that's generating the errors? check against the row number in log vs data.
and try the following:
input(datereturned, ?? mmddyy10.);
You've declared the variable character in your length statement first.
length _ datereturned $10.;
Try removing that line and see what you get.
Hi Reeza,
It doesn't work.
Error message:
NOTE: Invalid argument to function INPUT at line 22 column 21.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
What does your field currently look like? Do you have missing?
Post the full log with the error message so that we can see what's causing the error.
Hi Reeza,
Yes the field has missing values
Attached the screen shot for your reference.
It's the missing that's generating the errors? check against the row number in log vs data.
and try the following:
input(datereturned, ?? mmddyy10.);
length _datereturned $10.;
Why do you define _datereturned as character variable, since you want it be numeric.
Remove this statement.
Tried the below code and it worked well
data want (drop=LAST_SURVEY_DATE1);
set have;
format LAST_SURVEY_DATE mmddyy10.;
LAST_SURVEY_DATE = input(LAST_SURVEY_DATE1, ?? yymmdd10.);
run;
Thanks for all your responses.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.