<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to append a character string more than 32767 in one variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392455#M94436</link>
    <description>&lt;P&gt;I'm not sure that I understand what kind of data you are dealing with.&lt;/P&gt;
&lt;P&gt;Quoting from your post:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; "&lt;STRONG&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;cat&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;catx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token string"&gt; '&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cat&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;strip&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;STRONG&gt;sas_code&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;"I am trying to append observations of a &lt;STRONG&gt;sas dataset&lt;/STRONG&gt;&amp;nbsp;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;"&lt;SPAN&gt;For example if I am reading the query line by line then few&amp;nbsp;case when statements &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;woulb have been bifurcated into &lt;STRONG&gt;more than one line".&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to quoted post lines it seems that your &lt;STRONG&gt;sas dataset&lt;/STRONG&gt; is &lt;U&gt;actualy&lt;/U&gt; a &lt;STRONG&gt;sas program.&lt;/STRONG&gt; Isn't it ?&lt;/P&gt;
&lt;P&gt;If it is then try create a dataset with two varaibles:&lt;/P&gt;
&lt;P&gt;(1) sequnce nomber (2) a variable each containing one statement ending with a semicolon.&lt;/P&gt;
&lt;P&gt;I believe you are looking for case combinations taken from one statement only (spread in one or more lines)&lt;/P&gt;
&lt;P&gt;and not from severeal statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is a program, don't you have it as a text &lt;STRONG&gt;.sas&lt;/STRONG&gt; file ?&lt;/P&gt;
&lt;P&gt;If positive read it with &lt;STRONG&gt;INFILE&lt;/STRONG&gt; and &lt;STRONG&gt;dlm=';'&lt;/STRONG&gt;.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Sep 2017 09:16:28 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-09-01T09:16:28Z</dc:date>
    <item>
      <title>How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392442#M94428</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data D2;
length cat $32690;
do until (last.l);
set D1;
by l notsorted;
cat=catx(' ',cat,strip(sas_code)); 
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi Folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to append observations of a sas dataset into one character variable. Now, the varible length is going beyond 32767 in length, so it's trimming the chracters after that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please suggest me how to store the remaining character strings after 32767 position into other variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example I have one proc sql; query which is having lot of case when statements and those statements I am trying to append into a single line one after another, but problem is once it's reaching to 32767 characters then it's not appending further.(in the given code above, consider the &lt;STRONG&gt;sas_code&lt;/STRONG&gt; is having the big query and &lt;STRONG&gt;l&lt;/STRONG&gt; is the grouping of line numbers based on proc and quit as start and end point)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me how to store the remaing case when statements after 32767 characters into another variable, because I need the complete proc sql; till quit; query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 07:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392442#M94428</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-01T07:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392443#M94429</link>
      <description>&lt;P&gt;Why? What is wrong with storing the code in multiple observations?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 07:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392443#M94429</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-01T07:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392449#M94433</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for replying. I need the multiple observation into a single line becasue I need to capture sas query between proc and quit, same as between data and run. So that I can pull the required information from the query with help of string funtions available in SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example if I am reading the query line by line then few&amp;nbsp;case when statements woulb have been bifurcated into more than one line, so if I can combine all the line into one then I can retriev the complete query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this information will help.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 07:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392449#M94433</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-01T07:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392455#M94436</link>
      <description>&lt;P&gt;I'm not sure that I understand what kind of data you are dealing with.&lt;/P&gt;
&lt;P&gt;Quoting from your post:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; "&lt;STRONG&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;cat&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;catx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token string"&gt; '&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;cat&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;strip&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;STRONG&gt;sas_code&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;"I am trying to append observations of a &lt;STRONG&gt;sas dataset&lt;/STRONG&gt;&amp;nbsp;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;"&lt;SPAN&gt;For example if I am reading the query line by line then few&amp;nbsp;case when statements &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;woulb have been bifurcated into &lt;STRONG&gt;more than one line".&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to quoted post lines it seems that your &lt;STRONG&gt;sas dataset&lt;/STRONG&gt; is &lt;U&gt;actualy&lt;/U&gt; a &lt;STRONG&gt;sas program.&lt;/STRONG&gt; Isn't it ?&lt;/P&gt;
&lt;P&gt;If it is then try create a dataset with two varaibles:&lt;/P&gt;
&lt;P&gt;(1) sequnce nomber (2) a variable each containing one statement ending with a semicolon.&lt;/P&gt;
&lt;P&gt;I believe you are looking for case combinations taken from one statement only (spread in one or more lines)&lt;/P&gt;
&lt;P&gt;and not from severeal statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is a program, don't you have it as a text &lt;STRONG&gt;.sas&lt;/STRONG&gt; file ?&lt;/P&gt;
&lt;P&gt;If positive read it with &lt;STRONG&gt;INFILE&lt;/STRONG&gt; and &lt;STRONG&gt;dlm=';'&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 09:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392455#M94436</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-09-01T09:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392468#M94444</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes My input is SAS code itself. The infile statement will read line by line &amp;amp; we need data in concatenated&amp;nbsp;manner.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 09:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392468#M94444</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-01T09:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392470#M94446</link>
      <description>&lt;P&gt;Can you post the cases you are looking for by sql ?&lt;/P&gt;
&lt;P&gt;Are you looking for strings in different sas statemnets ?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 09:41:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392470#M94446</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-09-01T09:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392496#M94463</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;something like this?&lt;/P&gt;&lt;PRE&gt;%macro doit;
   %macro t;%mend t;
   PROC SQL noprint;
      select ceil(sum(length(name))/50)  into:nvars TRIMMED
      from sashelp.class
      ;
   QUIT;

   DATA D2;
      length len 8;
      %do i=1 %to &amp;amp;nvars.;
         length cat&amp;amp;i. $32690;
         retain cat&amp;amp;i. '';
      %end;
      set sashelp.class;
      retain len 0 varcount 1;
      len=len+length(name);

      if len&amp;gt;50 then do;
         len=length(name);
         varCount=varCount+1;
      end;

      array vars(*) cat1-cat&amp;amp;nvars.;
      do i=varCount to varCount;
         vars(i)=catx(' ',vars(i),strip(name)); ;
      end;
   RUN;

%mend doit;
%doit;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="splitString.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14781iA11E1729143E3EEF/image-size/large?v=v2&amp;amp;px=999" role="button" title="splitString.png" alt="splitString.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 11:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392496#M94463</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-09-01T11:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392497#M94464</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;,case when STATUS_CODE LIKE '%VP%' then 
     SUBSTR (STATUS_CODE , INDEX ( STATUS_CODE , 'VP'),2) 
    else '' end length=2 AS VP_STATUS 
  
  
  ,case when STATUS_CODE LIKE '%VP%' then 
     SUBSTR (REASON_CODE , INDEX ( STATUS_CODE , 'VP'),2) 
    else '' end length=2 AS VP_REASON
  
  
  ,case when STATUS_CODE LIKE '%VP%' then
    input(SUBSTR (STATUS_DATE , (INDEX ( STATUS_CODE , 'VP') * 3)-2  ,4) || '-' 
 || 
     SUBSTR (STATUS_DATE , (INDEX ( STATUS_CODE , 'VP') * 3)+2  ,2) || '-' || 
     SUBSTR (STATUS_DATE , (INDEX ( STATUS_CODE , 'VP') * 3)+4  ,2) ,yymmdd10.) 
    else . end format date9.  AS VP_DATE&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Suppose like in the above example there are more than 100 "case when" statements written line by line in a .sas file. So if I read by infile statement it will read without hassel as all the lines of code are less than 32767 characters, but when I will append it into a single line then I can get the complete query at one line and it can be more than 32767 characters.&amp;nbsp;I think it will be easy for me to pull any one case when statement from the bunch of case when statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when STATUS_CODE LIKE '%VP%' then SUBSTR (STATUS_CODE , INDEX ( STATUS_CODE , 'VP'),2) else '' end length=2 AS VP_STATUS ,case when STATUS_CODE LIKE '%VP%' then SUBSTR (REASON_CODE , INDEX ( STATUS_CODE , 'VP'),2) else '' end length=2 AS VP_REASON&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Now if I get the query like the above appended manner then I think if I want to retrieve only the below query then I can easily retrieve that with help sas string functions with some postional parameters. like Find or Findw funtions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when STATUS_CODE LIKE '%VP%' then SUBSTR (STATUS_CODE , INDEX ( STATUS_CODE , 'VP'),2) else '' end length=2 AS VP_STATUS&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; So, I just wanted to know, how to store the remaining caharacters from the point it will exceed 32767 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this much of information will help.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 11:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392497#M94464</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-01T11:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392508#M94470</link>
      <description>&lt;P&gt;Thanks oligoals for your effort. I am just wondering if there are texts between 2 specific keywords will it pull the data based on that!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like for example: if I have something like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hello&lt;/P&gt;
&lt;P&gt;xyz&lt;/P&gt;
&lt;P&gt;xyz&lt;/P&gt;
&lt;P&gt;xuz&lt;/P&gt;
&lt;P&gt;xyuz&lt;/P&gt;
&lt;P&gt;xyz&lt;/P&gt;
&lt;P&gt;wordl;&lt;/P&gt;
&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;abc&lt;/P&gt;
&lt;P&gt;abc&lt;/P&gt;
&lt;P&gt;abc&lt;/P&gt;
&lt;P&gt;abc&lt;/P&gt;
&lt;P&gt;there;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will the code will append the text between hello and world including both hello and world.(hello xyz xyz xyz xyz world) and (hi abc abc abc abc there)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like in the terms of first. and last. manner of grouping between 2 keywords.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 12:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392508#M94470</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-01T12:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392813#M94562</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is a string which is greater than 32767 in length, so &amp;nbsp;is it possible in SAS to split the string till 32767 in to one variable and from 32768 to another variable??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Please help me if possible or just let me know how we can achieve this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 21:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392813#M94562</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-02T21:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392828#M94568</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13220"&gt;@rajdeep&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;SQL's exceeding 32KB of code. That sounds terrible to maintain.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;32KB is the limit for a SAS character variable and there is no way around it.&lt;/P&gt;
&lt;P&gt;You can either store your string in multiple character variables in a single observation or in multiple observations using some logic to determine when you have to switch over.&lt;/P&gt;
&lt;P&gt;You could for example for every new input variable first check how much you've stored already in the current variable (using a length statement) and how long your new source string is - if there is no further space left then store the string in the next variable/next observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is simply about implementing some sort of a text search function out of SAS then consider to use OS text search functions instead which you can call out of SAS using a PIPE - and then only store the wanted result in SAS. UNIX/Linux for example provides very powerful commands for such tasks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 01:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392828#M94568</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-09-03T01:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392956#M94608</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it will try to append whatever is in between 'Hello' and 'there;' into one variable.&lt;/P&gt;&lt;P&gt;If&amp;nbsp;the appending results in a variable length that exceeds what has been specified here:&lt;/P&gt;&lt;PRE&gt;len&amp;gt;50&lt;/PRE&gt;&lt;P&gt;then a new variable is created. (according to your first post, you want 32690 here)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have the code give it a try.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 10:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/392956#M94608</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-09-04T10:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/393122#M94661</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what would you do with all this SQL splitted into variables?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can't&amp;nbsp;you save it to a file?&lt;/P&gt;&lt;PRE&gt;data _Null_;
   file "C:\Users\&amp;amp;sysuserid.\Desktop\mySQLCode.txt";
   set sashelp.class;
   put name;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 08:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/393122#M94661</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-09-05T08:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/393137#M94662</link>
      <description>&lt;P&gt;No, I need it insdie a variable or a column, so that I can pull the relevant information from that inside SAS environment. Bcoz my input itself a SAS Code only. I am reading it like how we read the log files inside the SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm just capturing the all the codes inside a variable which is been wriiten between proc and quit, it's appending line by line info and capturing fine for small codes, but for bigger proc sql queries it's cutting the string after 32767.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I just asked you earlier will your given code will capture the data between certain keywords like hello and there or proc or sql.&amp;nbsp;or it will just append the data&amp;nbsp;based on the length of the string value.(like len &amp;gt;50)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyways, I will test your code and will revert back. Apart from my requirement I just wanted to know for my knowledge that if there is a string more than 32767 characters then how to split the string and store it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Cheers......................&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 09:56:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/393137#M94662</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-05T09:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/393265#M94688</link>
      <description>&lt;P&gt;Well I'm not sure if I would really proceed this with SAS.&lt;/P&gt;&lt;P&gt;One could try to extract all the procedures from the log using a powershell RegEx script, depending of the exact requirements it may reach a much better performance.&lt;/P&gt;&lt;P&gt;But using SAS, this should work for you:&lt;/P&gt;&lt;PRE&gt;%MACRO splitIntoVars(inputDS=,outputDs=,VarToSplit=,VarLimit=);
   %macro t;%mend t;
   /*
      Concatenates the *VarToSplit* variable into cat* variables of *VarLimit* length
      Whenever a cat variable has reached the *VarLimit* length, a new cat* variable is created
   */
   PROC SQL noprint;
      select ceil(sum(length(&amp;amp;VarToSplit.))/&amp;amp;VarLimit.) into:nvars TRIMMED
      from &amp;amp;inputDS.
      ;
   QUIT;

   DATA &amp;amp;outputDs.;
      %do n=1 %to &amp;amp;nvars.;
         length cat&amp;amp;n. $&amp;amp;VarLimit.;
         retain cat&amp;amp;n. '';
      %end;
      set &amp;amp;inputDS.;
      retain o_limit &amp;amp;VarLimit. o_reached 0 o__n 1;
      array vars(*) cat1-cat&amp;amp;nvars.;

      o_Remaining=length(&amp;amp;VarToSplit.);
      o_from=1;
      o_to=min(o_limit-o_reached,length(&amp;amp;VarToSplit.));
      do while(o_Remaining&amp;gt;=1);
         o_text=substr(&amp;amp;VarToSplit.,o_from,o_to);
         %*Debug: put o__n= name= o_reached= o_remaining= o_from= o_to= o_text=;
         vars(o__n)=cats(' ',vars(o__n),substr(&amp;amp;VarToSplit.,o_from,o_to));   
         o_Remaining=o_Remaining-o_to;
         o_reached=o_reached+o_to;
         o_from=o_from+o_to;
         o_to=min(o_Remaining,o_limit);
         if o_reached eq o_limit then do;
            o__n=o__n+1;         
            o_reached=0;
         end;
      end;
      drop o_:;
   RUN;
%MEND splitIntoVars;
%splitIntoVars(inputDS=sashelp.class,outputDs=test,VarToSplit=name,VarLimit=50);&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 15:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/393265#M94688</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-09-05T15:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/393470#M94757</link>
      <description>&lt;P&gt;Thanks Oligoals for your effort. Let me tell you what I had done for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data D1;
set test2; 
/* cnt=length(sas); */
cnt1=length(sas_code);
   if 
   Findw(sas_code,'Proc') or Findw(sas_code,'PROC') or Findw(sas_code,'proc') or 
   scan(sas_code,1)='Data' or Scan(sas_code,1)='data' or scan(sas_code,1)='DATA' then 
   do;
   l+1;
   end;
   else do;
   l+0;
   end;

run;



data D2;
/* length cat $32690; */
length cat $32690;
do until (last.l);
set D1;
by l notsorted;
cat=catx(' ',cat,strip(sas_code)); 
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, in the D2 dataset it's appending the query, so when the query length is going beyond 32767 then it's trimming it. I would like to store the remaining in other variable in the D2 datastep itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;NOTE: test2 is the sas code itself.&lt;/P&gt;
&lt;P&gt;Is it possible in realtime?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 09:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/393470#M94757</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2017-09-06T09:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/394156#M94945</link>
      <description>&lt;P&gt;Did you try the code I sent you?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 08:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/394156#M94945</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-09-08T08:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/651449#M195464</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/77163"&gt;@Oligolas&lt;/a&gt;&amp;nbsp;sir,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code is helpful for me. But If I want to concatenate by group like 'Sex' variable, what lines I need to add or what will be the code? Can you please help me on that? I have attached an image of my result but problem it is not capturing more than 32767 character. My code is as below. Many Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data part4 (keep=DOC_NUMBER original_variable count);&lt;BR /&gt;set part3;&lt;BR /&gt;BY DOC_NUMBER;&lt;BR /&gt;if FIRST.DOC_NUMBER then&lt;BR /&gt;Count = 0;&lt;BR /&gt;Count + 1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data part5;&lt;BR /&gt;length concatenated_field $ 32767;&lt;BR /&gt;retain concatenated_field;&lt;BR /&gt;set part4;&lt;BR /&gt;by DOC_NUMBER;&lt;BR /&gt;if first.DOC_NUMBER then&lt;BR /&gt;do;&lt;BR /&gt;concatenated_field = original_variable;&lt;BR /&gt;end;&lt;BR /&gt;else&lt;BR /&gt;do;&lt;BR /&gt;concatenated_field = catx(', ', concatenated_field, original_variable);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 16:10:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/651449#M195464</guid>
      <dc:creator>benhaz</dc:creator>
      <dc:date>2020-05-28T16:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a character string more than 32767 in one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/652654#M195967</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256541"&gt;@benhaz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try this:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;PRE&gt;%MACRO doit;
   %macro t;%mend t;

   %let maxVarLength=20;

   proc sort data=sashelp.class(rename=(name=original_Variable sex=doc_Number)) out=have; by doc_Number original_Variable; run;

   *Determine variables that can be grouped together and still do not to exceed the maxVarLength;
   DATA _tempLen;
      length len 8;
      set have;
      by doc_Number;
      retain len 0 varcount 1;
      *Calculate length of concatenated field; 
      len=len+length(original_Variable);
      *Count space between variables;
      if len ne length(original_Variable) then len=len+1;

      if first.doc_Number then do;
         varcount=1;
         len=length(original_Variable);
         frst=1;
      end;
      else if len&amp;gt;&amp;amp;maxVarLength. then do;
         len=length(original_Variable);
         varCount=varCount+1;
         frst=1;
      end;
   RUN;

   *Determine how much concatenated fields are needed;
   PROC SQL noprint;
      select max(varCount) into:nvars TRIMMED
      from _tempLen
      ;
   QUIT;

   *Concatenate the original variable;
   DATA want;
      %do i=1 %to &amp;amp;nvars.;
         length concatenated_Field&amp;amp;i. $&amp;amp;maxVarLength.;
         retain concatenated_Field&amp;amp;i. '';
      %end;
      set _tempLen;
      by doc_Number;

      array vars(*) concatenated_Field1-concatenated_Field&amp;amp;nvars.;
      do i=varCount to varCount;
         if frst then vars(i)='';
         vars(i)=catx(' ',vars(i),strip(original_Variable)); ;
      end;

      drop len varCount frst i;
   RUN;

   PROC DATASETS lib=work nolist; delete _tempLen; RUN;QUIT;
%MEND doit;
%doit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jun 2020 19:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-a-character-string-more-than-32767-in-one-variable/m-p/652654#M195967</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2020-06-02T19:48:28Z</dc:date>
    </item>
  </channel>
</rss>

