proc format;
invalue $newdate '01JAN1990'd - '31DEC2004'd = 'Too Early'
'01JAN2005'd - '31DEC2005'd = [mmddyy10.]
'01JAN2007'd - high = 'Too Late';
run;
After running this, I kept getting the following error:
ERROR: These two ranges overlap: '01JAN1990'd-'31DEC2004'd and '01JAN2007'd-HIGH (fuzz=0).
ERROR: These two ranges overlap: '01JAN2007'd-HIGH and '01Jan2005'd-'31DEC2005'd (fuzz=0).
Thanks.
I can't test it at the moment, but will the error go away if you replace - with <-
Art
You don't want an INFORMAT you want a FORMAT. Then use a FORMAT statement to format the date variable.
proc format;
value newdate
'01JAN1990'd - '31DEC2004'd = 'Too Early'
'01JAN2005'd - '31DEC2005'd = [mmddyy10.]
'01JAN2007'd - high = 'Too Late';
run;
I'm sure that data_null has already provided the correct answer but, while you make the change, is there a reason why you don't include 2006 in your ranges?
I can make the code work by using FORMAT.
Just one more question, why can I not use INFORMAT here?
* To Art297: The range should be till the end of 2006. Thanks for pointing that out.
Southwind wrote:
I can make the code work by using FORMAT.
Just one more question, why can I not use INFORMAT here?
The INFORMAT code in your first post using the SAS date constant implies that you HAVE a variable that is a SAS DATE you want to display in a specific way. If that is not correct you need to be specific about what you have and what you want not just "what's wrong with this"...
Given that I believe your starting point in a SAS DATE and you want to display Too Early, Too Late or MMDDYY you need a FORMAT not an INFORMAT.
You could write a Rube Goldberg Machine http://en.wikipedia.org/wiki/Rube_Goldberg_machine program using an INFORMAT but that would be silly.
It is very interesting.
It looks like that proc format does not recognize the date constant '01jan2001'd ,when I use number of date to instead of '01jan2001'd. the code passed.
proc format; invalue $ newdate 10958 - 12000 = 'Too Early' 16000 - high = 'Too Late'; run; data xx; do date='01jan1990'd to '01jan2011'd; output; end; format date mmddyy10.; run;
Ksharp
Message was edited by: xia keshan
data xx;
input date $newdate20.;
datalines;
31JAN1990
;
run;
proc print data=xx;
run;
Thank you Ksharp. I tested and it worked like charm.
The two main problems I see with doing what I think you want to do with an INFORMAT are what you are inputting and what you are outputting.
You are attempting to define a character informat but the MMDDYY format is a numeric format. It outputs a numeric date not a character string.
You are attempting to define the inputs as date constants, but informats need character strings as inputs. That is why it complains about overlapping ranges. '01JAN1990' is less than '01JAN2007' which is less than '31DEC2004' because '19' < '20' and '31' > '01'.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.