I am using the dataset to create the formats and in that I have coded values itself has "LOW", "HIGH" when i create formats out of it I am getting error "ERROR: These two ranges overlap: ". I gave the Type also as "C" to consider as character format but still sas is treating "LOW" /"HIGH" as key words and treating as range..Kindly help to resolve this. Below is an example dataset created to explain for example. Is there a way to mask this? For all others I am able to create the formats without any issues.
/****************************************/
data fmt;
retain fmtname "$NRIND";
length start $100. label $100.;
start = "ABNORMAL";
label = "abnormal";
type = "C";
output;
start = "NORMAL";
label = "normal";
type = "C";
output;
start = "HIGH";
label = "high";
type = "C";
output;
start = "LOW";
label = "low";
type = "C";
output;
run;
proc format cntlin=fmt;
run;
/****************log************/
97 proc format cntlin=fmt;
ERROR: These two ranges overlap: LOW-LOW and ABNORMAL-ABNORMAL (fuzz=0).
ERROR: These two ranges overlap: HIGH-HIGH and NORMAL-NORMAL (fuzz=0).
98 run;
WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Add the HLO variable, so that it becomes clear these are not the usual HIGH and LOW values:
data fmt;
retain
fmtname "$NRIND"
type "C"
hlo ""
;
length start $10. label $10.;
input start label;
datalines;
ABNORMAL abnormal
NORMAL normal
HIGH high
LOW low
;
proc format cntlin=fmt;
run;
Log:
73 data fmt; 74 retain 75 fmtname "$NRIND" 76 type "C" 77 hlo "" 78 ; 79 length start $10. label $10.; 80 input start label; 81 datalines; NOTE: The data set WORK.FMT has 4 observations and 5 variables. NOTE: Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit): real time 0.00 seconds cpu time 0.00 seconds 86 ; 87 88 proc format cntlin=fmt; NOTE: Format $NRIND is already on the library WORK.FORMATS. NOTE: Format $NRIND has been output. 89 run;
Don't use DATATYPE, you don't need it here, and it has a special function.
data fmt;
retain
fmtname "$NRIND"
type "C"
;
length start $10. label $10.;
input start label;
datalines;
ABNORMAL abnormal
NORMAL normal
HIGH high
LOW low
;
Add the HLO variable, so that it becomes clear these are not the usual HIGH and LOW values:
data fmt;
retain
fmtname "$NRIND"
type "C"
hlo ""
;
length start $10. label $10.;
input start label;
datalines;
ABNORMAL abnormal
NORMAL normal
HIGH high
LOW low
;
proc format cntlin=fmt;
run;
Log:
73 data fmt; 74 retain 75 fmtname "$NRIND" 76 type "C" 77 hlo "" 78 ; 79 length start $10. label $10.; 80 input start label; 81 datalines; NOTE: The data set WORK.FMT has 4 observations and 5 variables. NOTE: Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit): real time 0.00 seconds cpu time 0.00 seconds 86 ; 87 88 proc format cntlin=fmt; NOTE: Format $NRIND is already on the library WORK.FORMATS. NOTE: Format $NRIND has been output. 89 run;
LOW and HIGH are reserved word of format procedure, usually used as:
LOW - <value1>
<valuen> - HIGH
that the reason you got the These two ranges overlap:
"These two ranges overlap:" error messages.
Beyond, I had never used the DATATYPE= variable and you can omit it.
As @Kurt_Bremser have shown you can add the TYPE to the RETAIN statement.
Do it like this it will work
data test_fmt; length label $15; fmtname='range'; input start $ end $ label :$; datalines; LOW 20 "good" 21 high "excellent" other . "missing" ; run;
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 16. 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.