- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You've declared the variable character in your length statement first.
length _ datereturned $10.;
Try removing that line and see what you get.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Reeza,
Yes the field has missing values
Attached the screen shot for your reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
length _datereturned $10.;
Why do you define _datereturned as character variable, since you want it be numeric.
Remove this statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.