BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PierreYvesILY
Pyrite | Level 9

dear SAS experts,

I want to create a SAS Format using a dataset.

I used following code:

proc sort data=Filialstruktur_Ergaenzt (keep=filbez_bt_dashb filhb_bt_ec) noduplicate; by filbez_bt_dashb; run;

data fmt_filiale;

set Filialstruktur_Ergaenzt(rename=(filbez_bt_dashb=start filhb_bt_ec=label)) end=last;

retain fmtname 'Filiale';

output;

run;

proc format cntlin=fmt_filiale; run;

 

and I got the following error message:

 

26 data fmt_filiale;
27 set Filialstruktur_Ergaenzt(rename=(filbez_bt_dashb=start filhb_bt_ec=label)) end=last;
28 retain fmtname 'Filiale';
29 output;
30 run;

NOTE: There were 1072 observations read from the data set WORK.FILIALSTRUKTUR_ERGAENZT.
NOTE: The data set WORK.FMT_FILIALE has 1072 observations and 3 variables.
NOTE: Compressing data set WORK.FMT_FILIALE increased size by 12.50 percent.
Compressed is 9 pages; un-compressed would require 8 pages.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

31 proc format cntlin=fmt_filiale;
ERROR: This range is repeated, or values overlap: .-..
31 ! 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.02 seconds

NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1072 observations read from the data set WORK.FMT_FILIALE.

 

How can I correct this?

Thank you in advance,

Regards

PY

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Since you want a format to translate from a character string, the name of the format should begin with a dollar sign.

 

retain fmtname '$Filiale';

View solution in original post

8 REPLIES 8
Kurt_Bremser
Super User

Inspect and correct your data, so that it fulfills the requirements for a valid format.

Also do not forget to set the format type.

For in-depth help, we would need to see the whole dataset.

And if you want to prevent a duplicate of the key, you have to use nodupkey in the proc sort, not noduplicate, which is an alias for noduprec.

Jagadishkatam
Amethyst | Level 16
Unless we know the data within the Filialstruktur_Ergaenzt dataset, we cannot help you. So please post the sample data so as to help you with the code.
Thanks,
Jag
PierreYvesILY
Pyrite | Level 9

here is the complete dataset and then the problematic code:

 

data Filiale_Ergaenzung;
length filhb 5 filialname $35 ;
input filhb filialname ;
datalines;
91100 Sonstige_ZE
99991 Vermittler
99992 Online
99993 Direktvertrieb
99994 P7S1
99995 DrKlein
99999 Nicht_zustellbar
;
run;
proc sort data=Filiale_Ergaenzung nodupkey; by filialname;run;

data fmt;
set Filiale_Ergaenzung(rename=(filialname=start filhb=label)) end=last;
length start $35 label 5;
retain fmtname 'Filiale' type 'N';
output;
run;
proc format cntlin=fmt;run;

Jagadishkatam
Amethyst | Level 16

Your code is right, but since you are using the character values as start and label as numeric, then the type should be 'C'

 

data fmt;
set Filiale_Ergaenzung(rename=(filialname=start filhb=label)) end=last;
length start $35 label 5;
retain fmtname 'Filiale' type 'C';
output;
run;

proc format cntlin=fmt fmtlib;
run;
Thanks,
Jag
PierreYvesILY
Pyrite | Level 9

Hello Kurt,

 

I need : Filialname => filhb

Kurt_Bremser
Super User

If your filhb is actually numeric, then you would need an informat (type="I"), and use the INPUT() function to convert.

But since this is just a code, and not a number, I advise to store it as character in the first place, and use a character format.

Astounding
PROC Star

Since you want a format to translate from a character string, the name of the format should begin with a dollar sign.

 

retain fmtname '$Filiale';