BookmarkSubscribeRSS Feed
ZRick
Obsidian | Level 7

Is following allowed? looks ok, but 4 is defined twice in format, the result is using homie, not mid.

Can someone help explain?

proc format;

    value ne

        low -  4 = 'homie'

        4 - 8 = 'mid';

run;

data t;

    input amt;

    cards;

    4

    5

    ;

proc print data=t;

    format amt ne.;

run;

3 REPLIES 3
kuridisanjeev
Quartz | Level 8

I thought Mid will be displayed in the place of 4.

Because 4-8='mid' is the recent value in proc format.

So this is going to apply to "4"..

Regards..

Sanjeev.k

RLC
Calcite | Level 5 RLC
Calcite | Level 5

The best response is to submit yours statements and consult the ouptut...

Another idea... submit these 2 statements

format cntlout=poub ;run;

print label ;var fmtname start end sexcl eexcl;run;

Ouptut

                             Ending

Format   Starting value   value for    Start       End

name     for format       format       exclusion   exclusion

  NE         LOW              4          N          N

  NE          4               8          Y          N

Patrick
Opal | Level 21

Without testing I would have expected that an error gets thrown because of overlapping ranges. But no: Proc Format digests these overlapping values.

On my SAS9.3 Win64 installation the label from the lower range is taken independently in what order the ranges are defined with Proc Format (so it's always 'homie').

Wouldn't have thought about writing the format to a data set like RLC did. It's quite nice as it actually gives you an idea of what Proc Format does to deal with such an ambiguity.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1610 views
  • 0 likes
  • 4 in conversation