BookmarkSubscribeRSS Feed
Southwind
Calcite | Level 5

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.

8 REPLIES 8
art297
Opal | Level 21

I can't test it at the moment, but will the error go away if you replace - with <-

Art

data_null__
Jade | Level 19

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;

art297
Opal | Level 21

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?

Southwind
Calcite | Level 5

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.

data_null__
Jade | Level 19

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.

Ksharp
Super User

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

Southwind
Calcite | Level 5

data xx;

input date $newdate20.;

datalines;

31JAN1990

;

run;

proc print data=xx;

run;

Thank you Ksharp. I tested and it worked like charm.Smiley Happy

Tom
Super User Tom
Super User

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'.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 2070 views
  • 3 likes
  • 5 in conversation