DATA Step, Macro, Functions and more

This range is repeated, or values overlap

Reply
Frequent Contributor
Posts: 75

This range is repeated, or values overlap

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

Frequent Contributor
Posts: 82

This range is repeated, or values overlap

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;

PROC Star
Posts: 7,471

This range is repeated, or values overlap

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.

Super User
Posts: 10,023

This range is repeated, or values overlap

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

Valued Guide
Posts: 765

Re: This range is repeated, or values overlap

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.


Trusted Advisor
Posts: 1,301

This range is repeated, or values overlap

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

Ask a Question
Discussion stats
  • 5 replies
  • 10311 views
  • 4 likes
  • 6 in conversation