Hi,
I try to do this code:
proc sql;
update WORK.List
set New= catx('-', put(substr(New, 7, 4), $4.), put(datepart(Date), yymmdd10.), Name)
, Name=case when Name LIKE '%NOVA' then substr(Name, 1, length(Name)-4) end
;
I have this error:
In a call to the CATX function, the buffer allocated for the result was not long enough to contain the concatenation of
all the arguments. The correct result would contain 30 characters, but the actual result might either be truncated to 16
character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most
argument that caused truncation.
WARNING: In a call to the CATX function, the buffer allocated for the result was not long enough to contain the concatenation of
2 The SAS System 14:03 Friday, March 16, 2018
all the arguments. The correct result would contain 35 characters, but the actual result might either be truncated to 16
character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most
argument that caused truncation.
The result is a column in blanks, not the string truncated to 16, i don't understand what means calling environment to be completely blank.
I try to change length in proc sql like:
t1.New format=$100., but always same error. I think is because de limitation of buffer in catx.
How i can solve this problem?
Regards,
Aleixo
I try to change length in proc sql like:
t1.New format=$100.,
Changing the format attached to a variable does NOT change the length. If you want to set the LENGTH then use LENGTH= option instead. Note that in an SQL SELECT statement the value of the LENGTH= does not include the $ prefix for character variables as it does in the normal LENGTH statement you would use in a data step.
create table newtable as
select a,b,c,catx('_',a,b,c) as new length=100
from oldtable
;
Since I see this line:
update WORK.List
then that means that the variable NEW already exists in your data set. It probably has a length of 16 which is not likely to change with an UPDATE which means "change in place"
Try creating a new table..
I try to change length in proc sql like:
t1.New format=$100.,
Changing the format attached to a variable does NOT change the length. If you want to set the LENGTH then use LENGTH= option instead. Note that in an SQL SELECT statement the value of the LENGTH= does not include the $ prefix for character variables as it does in the normal LENGTH statement you would use in a data step.
create table newtable as
select a,b,c,catx('_',a,b,c) as new length=100
from oldtable
;
If you want more control over which 16 characters from your concatenated string are stored into the 16 character long variable NEW you could add a SUBSTR() function call.
proc sql;
update WORK.List
set New= substr(catx('-', substr(New, 7, 4), put(datepart(Date), yymmdd10.), Name),1,16)
, Name=case when Name LIKE '%NOVA' then substr(Name, 1, length(Name)-4) end
;
Note there is no need to use PUT() around the substr() function you had before.
Thank you very much all answers.
Tom i think is update statement you will update all observations. We have to add a else statement to update only the observations that you want. Am i right?
regards,
aleixo
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 16. Read more here about why you should contribute and what is in it for you!
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.