Hello
I need to work with a data set with a date field in chat format .
The format is $ATE9 and the informat is same $ATE9
Fr exampe: the date value looks like this 2020-12-2
My question: What is the format $ATE9?
How can I convert it to SAS date??
The is no built-in format $ATE
It must be a custom format, or a format created and saved by someone else. Look in your program to see if that is the case.
You can also use this option to ignore the format and apply your own.
options nofmterr;
Thanks:
So as I understand I need to write the following code and then the format is going out from the variable?
Will informat also go out?
(Remind that both format and informat are $ATE9 (As i understand it is user defined )
What is the way to return to default status after the proc sql?
options nofmterr;
proc sql;
create table as want
select date
from have
;
quit;
@Ronein wrote:
Thanks:
So as I understand I need to write the following code and then the format is going out from the variable?
Will informat also go out?
(Remind that both format and informat are $ATE9 (As i understand it is user defined )
Please give it a try and let us know what happens.
@Ronein wrote:
What is the way to return to default status after the proc sql?
options nofmterr; proc sql; create table as want select date from have ; quit;
options fmterr;
By the way, informats are irrelevant to SQL.
It is much more important to check the TYPE (and the LENGTH for character variables) than any FORMAT or INFORMAT that might (or might not) be attached to it.
If looks like your variable is of type CHAR and should have a length of 10 (not 9) to be able to store date strings with four digit years and hyphens.
If you use SAS code you can remove the format attached to variable which will make it easier to see what actual data is stored in the field.
So if your current dataset is named HAVE and the variable in question is named DATE then this code will make a new dataset named WANT with the format removed from the variable.
data want;
set have;
format date ;
run;
If you run this code and examine the resulting format for the variable X you may be able to deduce a likely cause.
data example; x='2021-12-2'; format x date9.; run; proc contents data=example; run;
For those not interested in actually running the code you can see the "format" that @Ronein has in his data. No custom format just the way SAS will report this particular incorrect attempt at assigning an existing format.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.