Help using Base SAS procedures

How do I exclude keywords in range [PROC FORMAT]

Reply
Contributor
Posts: 53

How do I exclude keywords in range [PROC FORMAT]

PROC FORMAT;     

      VALUE format5a 7 -< HIGH = '7 to max exclusive';     

      VALUE format6a LOW <- HIGH = 'All the range excluding min' ;       

run;

Above sends error.

I can do it without the excluding symbol (i.e. - rather than -<).

Contributor
Posts: 53

How do I exclude keywords in range [PROC FORMAT]

What options do I have to make it work?

PROC Star
Posts: 7,417

How do I exclude keywords in range [PROC FORMAT]

My initial guess is that it is either a bug or the documentation isn't correct.  According to the documentation it should work.

Contributor
Posts: 53

Re: How do I exclude keywords in range [PROC FORMAT]

166  PROC FORMAT;

167  VALUE format5a 7 -< HIGH = '7 to max exclusive';

                         ----

                         22

                         76

ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant,

              a datetime constant, a missing value.

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: The previous statement has been deleted.

168  VALUE format6a LOW <- HIGH = 'All the range' ;

                        -

                        22

                        200

ERROR 22-322: Syntax error, expecting one of the following: ',', -, =.

ERROR 200-322: The symbol is not recognized and will be ignored.

NOTE: The previous statement has been deleted.

169  run;

NOTE: PROCEDURE FORMAT used (Total process time):

      real time           15.56 seconds

      cpu time            1.56 seconds

NOTE: The SAS System stopped processing this step because of errors.

This is what I got....

Trusted Advisor
Posts: 1,301

How do I exclude keywords in range [PROC FORMAT]

The issue is not the condition it is the usage of high and low with this excluding symbol.  This exception is not in the documentation.

Super User
Super User
Posts: 6,706

Re: How do I exclude keywords in range [PROC FORMAT]

Not sure what you are trying to get SAS to do.

If you want the full range use LOW - HIGH.

I cannot see any meaning trying to exclude LOW or HIGH (whatever actual number they might be).

PROC Star
Posts: 7,417

Re: How do I exclude keywords in range [PROC FORMAT]

I can.  Any values EXCEPT the extreme outliers.

Contributor
Posts: 53

Re: How do I exclude keywords in range [PROC FORMAT]

My reason is simple, "I don't like minimum and maximum of a variable. "

Super User
Super User
Posts: 6,706

Re: How do I exclude keywords in range [PROC FORMAT]

You will need to use something other than (or in addition to) a format to eliminate the minimum and maximum observed values. HIGH and LOW in the VALUE statement just mean the largest and smallest floating point number possible on the machine's hardware.

Contributor
Posts: 53

How do I exclude keywords in range [PROC FORMAT]

     Ok, so it's not a defined (closed form) value?    

     Intuitively for me(person without computer related degree) if HIGH is defined to be a general term that maps itself onto the maximum value of given numeric variable then I think of it as just an object that is assigned with the maximum of given variable.

     Thanks for the info.

PROC Star
Posts: 7,417

Re: How do I exclude keywords in range [PROC FORMAT]

While the documentation doesn't appear to define them, low and high might be the lowest and highest values possible on one's system and, if so, it wouldn't have much applicability to exclude them.

However, if you wanted to create a format that excluded the highest are lowest values in your data, you could always created macro variables that set the values before defining the desired formats.  E.g.:

data have;

  informat dates date9.;

  format dates date9.;

  input dates;

  cards;

01dec2011

02dec2011

03dec2011

04dec2011

05dec2011

06dec2011

07dec2011

08dec2011

;

proc sql noprint;

  select distinct min(dates),max(dates)

    into :low,:high

      from have

  ;

quit;

PROC FORMAT;    

      VALUE format5a '05dec2011'd-< &HIGH = "12/5 to max exclusive";    

      VALUE format6a &LOW<-'08dec2011'd = "All the range excluding min";      

run;

data test;

  set have;

  format dates1 format5a.;

  format dates2 format6a.;

  dates1=dates;

  dates2=dates;

run;

Ask a Question
Discussion stats
  • 10 replies
  • 309 views
  • 3 likes
  • 4 in conversation