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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1238 views
  • 2 likes
  • 2 in conversation