- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hey all,
I am trying to format a date variable that currently has a date16 format.
There are . for missing values for the variable. I need to reformat this but I get an ERROR: There was a problem with the format so BEST. was used.
Not sure what is going on. or how to work around.
Thanks
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try this to reformat "mydate":
mydate=datepart(mydate);
put mydate mmddyyn8.;
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What does date16. look like? In my version of SAS date9. is the biggest format I can have.
Post what your dates currently look like and what you want them to look like, eg. reformat to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Reeza
29MAR2013:00:00:00
This is what they currently look like.
I want it to appear like this: 03292013
Thanks you for your help,
Martinez77
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try this to reformat "mydate":
mydate=datepart(mydate);
put mydate mmddyyn8.;
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I should have been a little more clear.
I have a variable in my data set name enrl_drop_dt which contains date values as below:
29MAR2013:00:00:00
There are missing values with a . if missing.
I need them to display as shown below:
03292013
I was hoping I could do it in a data step
Data bla;
set bla;
format enrl_drop_dt mmddyyy6.;
run;
I hope that shines some light
Thanks,
Martinez
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The format to use would be:
mmddyyn8.
There is some question as to whether that would apply as is, or whether you need to change your data as well:
enrl_drop_dt = datepart(enrl_drop_dt);
It all depends on what your variable contains. If it's a date variable, leave it as is. If it's a date-time variable, you'll have to apply DATEPART. So try it with just the format and see how the dates look. If they are far too large, apply DATEPART.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
all
Thank you all very much. I had a typo in my format. Fixed it and the datepart function worked great.
Another sas win.
Thanks,
Martinez
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So your variable is actually a datetime variable, not a date variable.
You can use some date formats specifically on datetime variables, but the one you require isn't...AFAIK. That leaves you with two options, 1) Recode your variable to a true date variable so you can apply the date variable or 2) Create your own format that you can apply.
The first option was suggested by CTorres above in a data step. The second partly depends on what version of SAS you have, do you have SAS 9.3. In SAS 9.3 you can use functions in a format so it becomes relatively straight forward then.