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

Hi all,

 

I want to use the code as below to avoid truncation.

 

proc format library=work;
 value $cmfreq
    "1" = "BID"
    "2" = "TID"
    "3" = "QID"
    other=[$100.]
    ;
run;

 

 

But how to use cntlin to replace this code.

data tmp_format;
	  set tmp_format;
	  by fmtname;
	  output;
	  if last.fmtname then do;
	  start='other';
	  end='other';
	  label='[$200.]';
	  output;
	  end;
	run;

The code as below is not work.

 

Thanks.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @Lee_wan,

 

I would mostly

  1. look at the CNTLOUT dataset of the format
  2. remember that CNTLIN datasets can be fairly "minimalist"
  3. create the CNTLIN dataset and compare it to the CNTLOUT dataset using PROC COMPARE.

In your example the result could be:

data fmt;
retain fmtname 'cmfreq' type 'C';
infile cards eof=eof;
input start $ label $;
output;
return;
eof:
  hlo='OF';
  label='$100.';
  output;
cards;
1 BID
2 TID
3 QID
;

proc format cntlin=fmt;
run;  

 

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

"The code as below is not work" tells us exactly nothing. Describe the problem, show the log.

I suspect you should start by looking at the HLO dataset variable, or maybe at the DEFAULT= option for the VALUE statement.

FreelanceReinh
Jade | Level 19

Hi @Lee_wan,

 

I would mostly

  1. look at the CNTLOUT dataset of the format
  2. remember that CNTLIN datasets can be fairly "minimalist"
  3. create the CNTLIN dataset and compare it to the CNTLOUT dataset using PROC COMPARE.

In your example the result could be:

data fmt;
retain fmtname 'cmfreq' type 'C';
infile cards eof=eof;
input start $ label $;
output;
return;
eof:
  hlo='OF';
  label='$100.';
  output;
cards;
1 BID
2 TID
3 QID
;

proc format cntlin=fmt;
run;  

 

ballardw
Super User

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the <> to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the <> icon or attached as text to show exactly what you have and that we can test code against.

 

 

Bad coding form for people without a lot of SAS experience to use

data tmp_format;
	  set tmp_format;
	  by fmtname;

as that completely overwrites your starting data set an if there is a logic error you will have to go back an recreate the original tmp_format.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 999 views
  • 0 likes
  • 4 in conversation