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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 3 replies
  • 1111 views
  • 0 likes
  • 4 in conversation