BookmarkSubscribeRSS Feed
dhana
Fluorite | Level 6

I have problem in loading the format to catalog. Below is the piece of code that i am trying

DATA GENDER;

     INPUT START $ LABEL $;

DATALINES;

M MALE

F FEMALE

;

RUN;

DATA GENDER;

     RETAIN FMTNAME 'GENDER';

     SET GENDER;

RUN;

PROC FORMAT LIBRARY=WORK CNTLIN=GENDER;

RUN;

I am getting the following error: The range is repeated, or values overlap

can someone help

Thanks

Dhanasekaran R

8 REPLIES 8
ieva
Pyrite | Level 9

Can’t explain why it exactly happens, but I think it is that format/informat question. If you add “$” before format name, it will work.  Smiley Happy

DATA GENDER;

     RETAIN FMTNAME '$GENDER';

     SET GENDER end=last;

RUN;

PROC FORMAT LIBRARY=WORK CNTLIN=GENDER;

RUN;

art297
Opal | Level 21

I agree with the solution (although it all could have been done in one datastep), but not the reason.  You were trying to assign a numeric format to a character value.

luisrafa3012198
Calcite | Level 5

That work for me, thanks

Ksharp
Super User

Or you need to specify which type of this format.

DATA GENDER;
     INPUT START $ LABEL $;
DATALINES;
M MALE
F FEMALE
;
RUN;

 

DATA GENDER;
     RETAIN FMTNAME 'GENDER' TYPE 'C';
     SET GENDER;
RUN;

 

PROC FORMAT LIBRARY=WORK CNTLIN=GENDER;
RUN;

Ksharp

MikeZdeb
Rhodochrosite | Level 12

Hi ... you have suggestions on how to correct the error.

Why did you get this message ...

The range is repeated, or values overlap

You only put part of the message in the posting ...

ERROR: This range is repeated, or values overlap: .-..

With the format name GENDER, you asked to create a numeric format.

PROC FORMAT sees start value is 'M' (character) and tries to do a

character-to-numeric conversion ... that makes the start value missing.

When there's no end value specified, end is set to the same value as

start and the range is . - . .  The same thing happens when start is

'F' ... the range is again .-. ... a repeated range.

If you experiment a bit ...

data gender;

retain fmtname 'gender';

input start $ label $;

datalines;

M MALE

;

run;

proc format library=work cntlin=gender;

select gender;

run;


actually works and creates a numeric format ...

----------------------------------------------------------------------------

|       FORMAT NAME: GENDER   LENGTH:    4   NUMBER OF VALUES:    1        |

|   MIN LENGTH:   1  MAX LENGTH:  40  DEFAULT LENGTH:   4  FUZZ: STD       |

|--------------------------------------------------------------------------|

|START           |END             |LABEL  (VER. V7|V8   27AUG2011:00:18:47)|

|----------------+----------------+----------------------------------------|

|               .|               .|MALE                                    |

----------------------------------------------------------------------------

as does ...

data gender;

retain fmtname 'gender';

input start $ label $;

datalines;

1 MALE

2 FEMALE

;

run;

proc format library=work cntlin=gender;

select gender;

run;


----------------------------------------------------------------------------

|       FORMAT NAME: GENDER   LENGTH:    6   NUMBER OF VALUES:    2        |

|   MIN LENGTH:   1  MAX LENGTH:  40  DEFAULT LENGTH:   6  FUZZ: STD       |

|--------------------------------------------------------------------------|

|START           |END             |LABEL  (VER. V7|V8   27AUG2011:00:20:04)|

|----------------+----------------+----------------------------------------|

|               1|               1|MALE                                    |

|               2|               2|FEMALE                                  |

----------------------------------------------------------------------------

In this case, the character-to-numeric conversion results is two, non-repeating ranges.


FriedEgg
SAS Employee

for such a simple format why not just explicitly define it using the format proc instead of through a datastep?

proc format;

values $genderfmt

'M' = 'Male'

'F' = 'Female';

run;

data genderfmt;

retail fmtname '$genderfmt' type 'c';

input start $ label $;

datalines;

M Male

F Female;

run;

proc format library=work cntlin=genderfmt;

run;

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473491.htm

jfgiraldo
Fluorite | Level 6

Although it may seem illogical, this can happen if you try to define a format like this:

 

proc format;
value
myvar_fmt
low-<0="a.0-10"
10-<20="b.10-20"
15-<25="c.15-25"
25-high="d.0->"
;
run;

 

Obviously, the intervals b and c overlaps.

Greetings

ballardw
Super User

@jfgiraldo wrote:

Although it may seem illogical, this can happen if you try to define a format like this:

 

proc format;
value
myvar_fmt
low-<0="a.0-10"
10-<20="b.10-20"
15-<25="c.15-25"
25-high="d.0->"
;
run;

 

Obviously, the intervals b and c overlaps.

Greetings


Maybe isn't needed to add to this 12 year old thread.

You value text for the format doesn't make sense given the range definition show for A.

 

However you can look at the MULTILABEL option for formats if you really need an overlapping range and pay attention to which Procedures can actually use Multilabel formats: Tabulate, Report, Means/Summary.

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!

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
  • 8 replies
  • 28560 views
  • 5 likes
  • 9 in conversation