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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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