🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 10-21-2020 04:33 PM
(831 views)
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 |
- Tags:
- sas
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I did proc content and it is saying data variable is Char. How do I change the format after proc content?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;