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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.