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.
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.
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.