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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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