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

 

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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.);

View solution in original post

7 REPLIES 7
Reeza
Super User

You've declared the variable character in your length statement first.

 

length _ datereturned $10.;

 

Try removing that line and see what you get.

cho16
Obsidian | Level 7

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.

 

Reeza
Super User

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.

cho16
Obsidian | Level 7

Hi Reeza,

 

Yes the field has missing values

 

Attached the screen shot for your reference.

Reeza
Super User

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.);

Ksharp
Super User

length _datereturned $10.;

 

Why do you define _datereturned as character variable, since you want it be numeric. 

Remove this statement.

cho16
Obsidian | Level 7

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.

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2360 views
  • 2 likes
  • 3 in conversation