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

Hello,

 

I have a dataset formatted in mmddyy10. but when I run the data, it keeps on telling me its in a character format even though it looks like in numeric format. How can I fix this? 

When I open the dataset this is what it looks like. 

Data
03/20/1997
.
04/21/2002
05/7/2019
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20


Data dates;
input char_Date :$12.;
cards;
03/20/1997
.
04/21/2002
05/7/2019
;

data num_sas_date;
 set dates;
 num_date=input(char_Date,mmddyy10.);
 format num_date mmddyy10.;
run;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

HI @hjjijkkl  Please run a PROC CONTENTS to check whether your Date variable is numeric/char. 

 

proc contents data=your_dataset;

run;

 

then do the conversion and formatting

hjjijkkl
Pyrite | Level 9
Yes, I did proc content and it is saying data variable is Char. How do I change the format after proc content?
ballardw
Super User

@hjjijkkl wrote:
Yes, I did proc content and it is saying data variable is Char. How do I change the format after proc content?

Create a new data set with a new variable:

 

data want;
   set have;
   newdate = input(chardate,mmddyy10.);
   format newdate mmddyy10.;
run;

Or possibly go back to the step where where the data was read into SAS and use the mmddyy10. informat to read the value.

novinosrin
Tourmaline | Level 20


Data dates;
input char_Date :$12.;
cards;
03/20/1997
.
04/21/2002
05/7/2019
;

data num_sas_date;
 set dates;
 num_date=input(char_Date,mmddyy10.);
 format num_date mmddyy10.;
run;

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 633 views
  • 0 likes
  • 3 in conversation