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

Hi!

 

When trying to include a format in another format I get a note saying:

NOTE: The $FIRSTFORMAT (in)format was specified on the right-hand side of an equal sign, but without a length specification. PROC
FORMAT will assume a default length of at least 40 for the format being generated. If this is an insufficient width, you can
rerun PROC FORMAT with an explicit width for the $FIRSTFORMAT (in)format, or provide a sufficient DEFAULT= option.

The Code looks something like this:

proc format lib=format.userformat;
value $firstformat
'3'='ThisIsAStringThatIsMoreThanFortyCharactersLong'
;
run;

proc format lib=format.userformat;
value $secondformat
'1'='AShortString'
'2'='AlsoAShortString'
other=[$firstformat.]
;
run;

data test;
length value $255.;
format value $secondformat.;
value='1';
output;
value='2';
output;
value='3';
output;
run;

The value '3' is truncated to 40 characters... What am I doing wrong? I've tried putting a  "default=50" after the value -statement (in both formats) but it doesn't seem to be doing anything.

How do I set an "explicit width for the $FIRSTFORMAT (in)format" or "provide a sufficient DEFAULT= option"?

 

The above code is obviously just an example... In reality the firstformat is created from a file and contains a lot of values, most of whom are longer than the values in secondformat. 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Simply set the length in the second format to the length you need. If you want 50 characters use:

proc format lib=format.userformat;
value $secondformat
'1'='AShortString'
'2'='AlsoAShortString'
other=[$firstformat50.]
;
run;

Or show the code where you attempted the default that did not perform as expected.

View solution in original post

2 REPLIES 2
ballardw
Super User

Simply set the length in the second format to the length you need. If you want 50 characters use:

proc format lib=format.userformat;
value $secondformat
'1'='AShortString'
'2'='AlsoAShortString'
other=[$firstformat50.]
;
run;

Or show the code where you attempted the default that did not perform as expected.

andypandy_swe
Obsidian | Level 7
I tried your code yesterday and it didn't work... Got the same result. Today it works. Must have had en EG hangup.
Thanks!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1311 views
  • 2 likes
  • 2 in conversation