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 |
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;
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 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.
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.