Help using Base SAS procedures

proc format cntlin error

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 18
Accepted Solution

proc format cntlin error

The following procudes the error: for format lookup_acbs, this range is repeated, or values overlap:

 

 

proc sort data=acbs nodupkey;
by acbs_products;
run;
 
data lookup_acbs; 
set acbs;
start=acbs_products;
label='KEEP';
fmtname='lookup_acbs';
 
proc format cntlin=lookup_acbs; run;
 

 

I am trying to create a format for a list of product names (approx 200), which look like...

 

CALOGEN

CALSHAKE

CARBZERO

CARE CO-LACTASE

...

 

 Obviously as I used 'proc sort nodupkey', there should be no duplicates... I wonder if anyone can tell me why the proc format is not working? Is it to do with the presence of spaces in the product names?

 

Many thanks,

 


Accepted Solutions
Solution
‎02-28-2017 08:36 AM
Super User
Posts: 6,939

Re: proc format cntlin error

Add a type to make the format a character format:

proc sort data=acbs nodupkey;
by acbs_products;
run;
 
data lookup_acbs; 
set acbs;
start=acbs_products;
label='KEEP';
type = 'C'; /* this is important */
fmtname='lookup_acbs';
run;
 
proc format cntlin=lookup_acbs;
run;

Otherwise, proc format tries to create a numeric format and gets only missing values, as the character values can't be converted to numeric.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎02-28-2017 08:36 AM
Super User
Posts: 6,939

Re: proc format cntlin error

Add a type to make the format a character format:

proc sort data=acbs nodupkey;
by acbs_products;
run;
 
data lookup_acbs; 
set acbs;
start=acbs_products;
label='KEEP';
type = 'C'; /* this is important */
fmtname='lookup_acbs';
run;
 
proc format cntlin=lookup_acbs;
run;

Otherwise, proc format tries to create a numeric format and gets only missing values, as the character values can't be converted to numeric.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 18

Re: proc format cntlin error

Thank you so much! I didn't realise I had to set it as a character format too.
Super User
Posts: 6,939

Re: proc format cntlin error

... and some SAS messages are not that intuitive, especially for newcomers Smiley Happy

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 225 views
  • 0 likes
  • 2 in conversation