08-13-2013 04:35 PM
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.
08-13-2013 04:37 PM
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.
08-13-2013 04:44 PM
This is what they currently look like.
I want it to appear like this: 03292013
Thanks you for your help,
08-13-2013 05:06 PM
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:
There are missing values with a . if missing.
I need them to display as shown below:
I was hoping I could do it in a data step
format enrl_drop_dt mmddyyy6.;
I hope that shines some light
08-13-2013 05:17 PM
The format to use would be:
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.
08-13-2013 05:26 PM
Thank you all very much. I had a typo in my format. Fixed it and the datepart function worked great.
Another sas win.
08-13-2013 05:24 PM
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.
Need further help from the community? Please ask a new question.