BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi !!
I need help here. I am getting an error for a CATX function. This is the code which erroes out:
/* transpose based on eid */
proc transpose data= stry
out= stry_tranposed(drop=_:) prefix=txt;
by eid ;
var msg_tx;
run;

/* concatenate txt fields delimited by "
" */
data output1;
set stry_tranposed;
length allTxt $32767;
allTxt = catx(" ", of txt:);
*allTxt = htmlencode(allTxt);
*allTxt = tranwrd(allTxt, "#br#", "
");
keep EID allTxt;

run;
"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 45369 characters, but the actual result may either be truncated to 32767 character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most argument that caused truncation.
NOTE: Argument 509 to function CATX at line 156 column 17 is invalid."
The log gives me multiple txt messages which is the data I am oncatenating.
Is there any other fucntion that does not have that does not have this limitation 0f 32767 chars.
Or maybe how can I handle this limitation? For eg if alltxt is more tahn 32767 chars then split it, because right now I am get no records if the chars are >32767.

Thanks!! Message was edited by: sasnewbee
12 REPLIES 12
CurtisMack
Fluorite | Level 6
If you are not seeing the line numbers this can be caused by running the DATA step within a MACRO block. The only way I know to get the line numbers is to recreate the conditions and logic in stand alone code. Annoying I know.


Sorry, but I don't have any insight into the limitation of the CATX function. This limitation and behavior is described in the documentation.

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002257076.htm
deleted_user
Not applicable
I have now changed my questiona little bit and wanted to know if the SAS limitation of 32767 chars can be overcome. Please help.


Thanks!!
chang_y_chung_hotmail_com
Obsidian | Level 7
> I [...] wanted to know if the SAS limitation of 32767 chars
> can be overcome.

No, it can't be. (AFAIK)
deleted_user
Not applicable
I have now changed my questiona little bit and wanted to know if the SAS limitation of 32767 chars can be overcome. Please help.


Thanks!!
Peter_C
Rhodochrosite | Level 12
> I have now changed my questiona little bit and
> wanted to know if the SAS limitation of 32767 chars
> can be overcome. Please help.
>
>
> Thanks!!

In what context can you use strings wider than 32767?
deleted_user
Not applicable
I am transposing the dataset and then using a catX on it.
So if the no of records under one id is say 100, then 100 variables are created after transpose and when I concatenate them into one, it exceeds 32767 chars. Is there a way, where we can detect when the chars become greater than 32KB and we can split the recors into 2 records.
Peter_C
Rhodochrosite | Level 12
OK
making a little more sense.
But - why would you want to hold all this text in a SAS data set?
peterC
deleted_user
Not applicable
I am actually trying to merge several messages under one ID into one message for each ID. Kind of forming a story for each id. This is a business requirement.

Any pointers to tackle this?
Ksharp
Super User
Hi.
After using char=catx(of ...),you can use length(char) to identify whether this variable is over range of 32767.



Ksharp
deleted_user
Not applicable
Hi Ksharp!
Thanks for your input.
Right now, when I am using just CATX, it will delete the all the messages in that id. So if id=1234 has greater than 32KB chars, the output does not have this id itself. So even if I use length(char) after CATX, I do not think it will work.

Is there a way we can just pass the first 32KB chars instead of just not having taht id in the output.

Thanks!!
Ksharp
Super User
Hi.
Maybe you need right code.
[pre]


[/pre]


proc sort data=sashelp.class;



 by sex;



run;



data want;



 set sashelp.class;



 by sex;



 length  whole $ 20; *20 is your 32760;



 retain whole '
'
;



 if first.sex then call missing (whole);



 if (20 - length(whole)) gt

length(name)
then whole=catx(' ',whole,name);



  else do;



        
output;



        
call missing(whole);



        
whole=catx(
' ',whole,name);



       end;



 if last.sex then output;



 keep sex whole;



run;


[pre]



Ksharp
[/pre]

Peter_C
Rhodochrosite | Level 12
> I am actually trying to merge several messages under
> one ID into one message for each ID. Kind of forming
> a story for each id. This is a business requirement.
>
>
> Any pointers to tackle this?

instead of "a variable" comprising the message, why not just make it "a list" (series of obs) - one line for each message of one ID? Message was edited by: Peter.C

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 12 replies
  • 5280 views
  • 0 likes
  • 5 in conversation