DATA Step, Macro, Functions and more

CATX function

Reply
N/A
Posts: 0

CATX function

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=_Smiley Happy prefix=txt;
by eid ;
var msg_tx;
run;

/* concatenate txt fields delimited by "
" */
data output1;
set stry_tranposed;
length allTxt $32767;
allTxt = catx(" ", of txtSmiley Happy;
*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
Frequent Contributor
Posts: 102

Re: CATX function

Posted in reply to deleted_user
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
N/A
Posts: 0

Re: CATX function

Posted in reply to CurtisMack
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!!
Regular Contributor
Posts: 241

Re: CATX function

Posted in reply to deleted_user
> I [...] wanted to know if the SAS limitation of 32767 chars
> can be overcome.

No, it can't be. (AFAIK)
N/A
Posts: 0

Re: CATX function

Posted in reply to CurtisMack
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!!
Valued Guide
Posts: 2,177

Re: CATX function

Posted in reply to deleted_user
> 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?
N/A
Posts: 0

Re: CATX function

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.
Valued Guide
Posts: 2,177

Re: CATX function

Posted in reply to deleted_user
OK
making a little more sense.
But - why would you want to hold all this text in a SAS data set?
peterC
N/A
Posts: 0

Re: CATX function

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?
Super User
Posts: 10,020

Re: CATX function

Posted in reply to deleted_user
Hi.
After using char=catx(of ...),you can use length(char) to identify whether this variable is over range of 32767.



Ksharp
N/A
Posts: 0

Re: CATX function

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!!
Super User
Posts: 10,020

Re: CATX function

Posted in reply to deleted_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]

Valued Guide
Posts: 2,177

Re: CATX function

Posted in reply to deleted_user
> 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
Ask a Question
Discussion stats
  • 12 replies
  • 2237 views
  • 0 likes
  • 5 in conversation