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

Ran into an interesting problem last night when using the cntlin option with proc format. The following code produces an error:

data for_format;
  input sym_root $;
  cards;
AAA
BBB
LOW
ZZZ
;
run;

data for_format;
  set for_format (rename=(sym_root=start));
  retain fmtname "$labelfmt" type "C";
  label=_n_;
run;

proc format cntlin = for_format;
run ;

Anyone know how one can include the value 'LOW' in such a case? My work around was to recode 'LOW' to be 'LOWW', but I'd rather no have to change the variable's value.

 

Art, CEO, AnalystFinder.com

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You need to add the HLO variable to your control dataset to prevent SAS from trying to detect the LOW HIGH keywords from the text of the START/END values.

data for_format;
  set have (rename=(sym_root=start));
  retain fmtname "$labelfmt" type "C" hlo '   ';
  label=_n_;
run;
proc format cntlin = for_format;
run ;

One way to test is to make the format using code and output the control dataset.

Then try keeping different subsets of the variables in that control dataset to pass back into PROC FORMAT to figure out the minimum set of variables that are needed.

proc format cntlout=want;
  value $labelfmt
  'AAA'='1'
  'BBB'='2'
  'LOW'='3'
  'ZZZ'='4'
  ;
run;

proc format cntlin=want(keep=fmtname type start label hlo); 
run;

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

You need to add the HLO variable to your control dataset to prevent SAS from trying to detect the LOW HIGH keywords from the text of the START/END values.

data for_format;
  set have (rename=(sym_root=start));
  retain fmtname "$labelfmt" type "C" hlo '   ';
  label=_n_;
run;
proc format cntlin = for_format;
run ;

One way to test is to make the format using code and output the control dataset.

Then try keeping different subsets of the variables in that control dataset to pass back into PROC FORMAT to figure out the minimum set of variables that are needed.

proc format cntlout=want;
  value $labelfmt
  'AAA'='1'
  'BBB'='2'
  'LOW'='3'
  'ZZZ'='4'
  ;
run;

proc format cntlin=want(keep=fmtname type start label hlo); 
run;
art297
Opal | Level 21

@Tom: Worked like a charm!

 

Thanks,

Art

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1033 views
  • 3 likes
  • 2 in conversation