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
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.
DATA GENDER;
RETAIN FMTNAME '$GENDER';
SET GENDER end=last;
RUN;
PROC FORMAT LIBRARY=WORK CNTLIN=GENDER;
RUN;
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.
That work for me, thanks
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
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.
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
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
@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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.