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

Hi Folks:

I'm baffled that seemingly correct solution to convert character date to numeric date doesn't work. According to the SAS Viewtable I'm using correct format YYMMDD10. in the code below.  However, the code below outputs missing Date1 variable. What am I doing wrong here, any idea? 

 

data time1; set time;
Date1=input(date,YYMMDD10.);
run;

date format.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

The variable DATE is already a a date.

You don't need to convert it.

You can change its associated format to display it differently.

 

View solution in original post

5 REPLIES 5
ballardw
Super User

INPUT works is to read a CHARACTER value for the first parameter using the informat specified in the second parameter.

Your Date is already numeric. So input isn't correct to use.

If you want to convert numeric to character then use PUT.

 

date1 = put(date,yymmdd10.);

or other format.

ChrisNZ
Tourmaline | Level 20

The variable DATE is already a a date.

You don't need to convert it.

You can change its associated format to display it differently.

 

Cruise
Ammonite | Level 13
Thanks.
format date best5.;
This did the job.
Cruise
Ammonite | Level 13
quite handy! thanks a lot for the trick.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 3695 views
  • 2 likes
  • 4 in conversation