Help using Base SAS procedures

CAT function buffer

Reply
N/A
Posts: 0

CAT function buffer

I am getting a warning while using simple string concatenation function CAT in the code line

%let outputFileNameCSV = CAT(outputFolderName,datasetName);

The warning says -
WARNING: In a call to the CAT function, the buffer allocated for the result was not long enough to contain the concatenation of all the arguments. The correct result would contain 527 characters, but the actual result may either be truncated to 200 character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most argument that caused truncation.


I checked the documentation and found this...

---------------------------------------------------------------------------------------------------------
Length of Returned Variable: Special Cases
The CAT function returns a value to a variable, or returns a value in a temporary buffer. The value that is returned from the CAT function has the following length:

up to 200 characters in WHERE clauses and in PROC SQL

up to 32767 characters in the DATA step except in WHERE clauses

up to 65534 characters when CAT is called from the macro processor

If CAT returns a value in a temporary buffer, the length of the buffer depends on the calling environment, and the value in the buffer can be truncated after CAT finishes processing. In this case, SAS does not write a message about the truncation to the log.

--------------------------------------------------------------------------------------------------------
The sentence "the length of the buffer depends on the calling environment" tells me that I can do something about the warning I'm getting. But I do not understand which option in SAS environment I need to tweak and how..

Can someone please point out how to do that?

Thanks,
Neel
Super Contributor
Super Contributor
Posts: 3,174

Re: CAT function buffer

Posted in reply to deleted_user
You have coded an incorrect usage of the CAT function, where to use it with the macro language you must code it with the %SYSFUNC macro function call. Consider also there is a limit to the max size of a SAS macro variable. And, when using the function in a DATA step, you really should consider declaring a LENGTH statement to ensure desired results with the assigned SAS dataset variable.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: CAT function buffer

Thanks Scott.

Will try with LENGTH statement.
N/A
Posts: 0

Re: CAT function buffer

Posted in reply to deleted_user
Yes Scott, changing the length to little higher value worked.

Thanks!
Ask a Question
Discussion stats
  • 3 replies
  • 2459 views
  • 0 likes
  • 2 in conversation