<?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: Problem with maximum length of expression in user transformation(SAS Data Integration Studio) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783313#M249738</link>
    <description>&lt;P&gt;Unsure of what your data is like, but it seems that this could help:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*FIRST POINT*/
data _null_;
    set product_table;
    .........
    /*some data step code*/
    .........
    put 'if PRODUCT =' PRODUCT $quote. ' then do;' ;
    put PROD_STATEMENT ;
    put 'end;' ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Dec 2021 05:15:10 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-12-01T05:15:10Z</dc:date>
    <item>
      <title>Problem with maximum length of expression in user transformation(SAS Data Integration Studio)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783273#M249713</link>
      <description>&lt;P&gt;Hi, SAS! I work in data integration studio and have problem with the length of expression:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ERROR: The text expression length (65535) exceeds maximum length (65534). The text expression has been truncated to 65534 characters.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It happens in my user written transform, when sas resolves macro variable:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let _OUTPUT1_col9_exp = /*{long expression, which contains very long data step code, for example: "if number=1 then do....end; if....." and has length &amp;gt;65535}*/;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I understand, that this very long text expression assigns in macro variable, and it has&amp;nbsp;&lt;SPAN&gt;length limit 65534&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but may be someone faced such problem and successfully solved it. My user written transformation doesn't allow me to split this macro variable into several macro variables, because it use in data step code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;..........&lt;BR /&gt;data &amp;amp;&amp;amp;_OUTPUT&amp;amp;mvI.(keep=&amp;amp;&amp;amp;_OUTPUT&amp;amp;mvI._keep &amp;amp;&amp;amp;_OUTPUT&amp;amp;mvI._options) %if "&amp;amp;&amp;amp;_OUTPUT&amp;amp;mvI._memtype" eq "VIEW" %then / view=&amp;amp;&amp;amp;_OUTPUT&amp;amp;mvI.;&lt;BR /&gt;    attrib&lt;BR /&gt;    /*{attrib code}*/&lt;BR /&gt;    set &lt;BR /&gt;     %do mvI=0 %to %eval(&amp;amp;_INPUT_count - 1);&lt;BR /&gt;        &amp;amp;&amp;amp;_INPUT&amp;amp;mvI. (in=in_&amp;amp;mvI. &amp;amp;&amp;amp;_INPUT&amp;amp;mvI._options)&lt;BR /&gt;    %end;    &lt;BR /&gt;    %do mvI=0 %to %eval(&amp;amp;&amp;amp;_OUTPUT&amp;amp;mvT._col_count - 1);&lt;BR /&gt;        %if "&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;mvI._exp" ne "" %then %do;&lt;BR /&gt;            &amp;amp;&amp;amp;_OUTPUT&amp;amp;mvT._col&amp;amp;mvI._exp;   &lt;FONT color="#0000FF"&gt;{&amp;lt;- this is the place, where this macro variable resolves}&lt;/FONT&gt;&lt;BR /&gt;        %end;&lt;BR /&gt;    %end;&lt;BR /&gt;run;&lt;BR /&gt;.......&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; I tried to split my code into several expressions:&lt;/P&gt;&lt;PRE&gt;%let _OUTPUT1_col9_exp = /*{part 1 of long expression, which contains very long data step code, for example: "if number=1 then do....end; if....." and has length &amp;gt;65535}*/;
%let _OUTPUT1_col10_exp = /*{part 2 of long expression, which contains very long data step code, for example: "if number=1 then do....end; if....." and has length &amp;gt;65535}*/;
%let _OUTPUT1_col11_exp = /*{part 3 of long expression, which contains very long data step code, for example: "if number=1 then do....end; if....." and has length &amp;gt;65535}*/;
......&lt;/PRE&gt;&lt;P&gt;but i have limited quantity of _OUTPUT1_col{n}_exp macrovariables, and it is not enough to fit this long expression.&lt;/P&gt;&lt;P&gt;Sorry for my English, I'm from Belarus&lt;span class="lia-unicode-emoji" title=":face_without_mouth:"&gt;😶&lt;/span&gt; and i don't hope that someone can help me with this problem.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 20:49:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783273#M249713</guid>
      <dc:creator>Realmadrid1992</dc:creator>
      <dc:date>2021-11-30T20:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with maximum length of expression in user transformation(SAS Data Integration Studio)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783275#M249714</link>
      <description>&lt;P&gt;Welcome to the community and congrats on a complete and well-formatted post!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no way to make the macro variables longer.&lt;/P&gt;
&lt;P&gt;You can either make several variables and call&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;           &amp;amp;&amp;amp;_OUTPUT&amp;amp;mvT._col&amp;amp;mvI._exp1&lt;/CODE&gt;&lt;CODE class=""&gt; &lt;BR /&gt;           &amp;amp;&amp;amp;_OUTPUT&amp;amp;mvT._col&amp;amp;mvI._exp2;   &lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or save your code in an external file and include it. Like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename TMP temp;
data _null_;
  file TMP ;
  put 'put "Hello!"; ';
run;

data _null_;
  %include TMP ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 21:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783275#M249714</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-30T21:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with maximum length of expression in user transformation(SAS Data Integration Studio)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783298#M249729</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/395053"&gt;@Realmadrid1992&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is certainly possible to solve this problem. The best solution will be to recode the expressions to a shorter form with the same functionality, and I&amp;nbsp;have an idea:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;User-written transformations do not generate any code that make use of the macro variables, they are only defined so the content is available to the user-written code, and anyhing that DI Studio accepts as a&amp;nbsp; syntactically correct expression will work. This means that the expression could be a macro call with&amp;nbsp;the input column name as argument.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you write the code in a macro and store the macro in a macro catalog allocated to the session, you could write the expression as&lt;/P&gt;
&lt;P&gt;%recodecolumn(input_variable) or whatever name you prefer for the macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro argument is there only to allow column mapping in DI Studio and thus preserving column-lineage.&amp;nbsp;The macro should contain the expression and nothing else. It&amp;nbsp;should resolve to code lines in the data step, so your data step should work as written without modifications, the only difference is that the code is supplied from the macro and not passed in the DI Studio generated macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let my know if you like the idea, and I will make a working example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 22:32:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783298#M249729</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2021-11-30T22:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with maximum length of expression in user transformation(SAS Data Integration Studio)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783304#M249735</link>
      <description>&lt;P&gt;I tried to use the "external file" way.&lt;BR /&gt;I didn't say, that my long text expression is the result of:&lt;BR /&gt;1. data step, which generate macro variables through the call symput statement&lt;BR /&gt;2. this macro variables generate my expression through the macro loop.&lt;/P&gt;&lt;P&gt;in short situation is:&lt;/P&gt;&lt;PRE&gt;/*FIRST POINT*/
data _null_;
    set product_table;
    .........
    /*some data step code*/
    .........
    call symput('mvCount',strip(product_count));
    call symput('mvProduct'||left(product_count),strip(product));
    call symput('mvProductStatement'||left(product_count),strip(prod_statement));
    output;
run;

/*SECOND POINT*/
%macro mExpressionMacroLoop;
    %do mvNum=1 %to &amp;amp;mvCount;
        if product=&amp;amp;&amp;amp;mvProduct&amp;amp;mvNum then do%str(;)
            &amp;amp;&amp;amp;mvProductStatement&amp;amp;mvNum;
	end%str(;)	
%mend mExpressionMacroLoop;&lt;/PRE&gt;&lt;P&gt;And now i need to write the result of execution of %mExpressionMacroLoop to TMP file. I know the call execute function, but i don't now how to connect it with PUT statement, which write to file:&lt;/P&gt;&lt;PRE&gt;filename TMP tmp;
data _null_;
    file  TMP;
    put '/*here i need to write the result of %mExpressionMacroLoop execution*/';&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;Could you help me with the PUT statement in this way, because i&amp;nbsp; worked with the external files by SAS very rarely and have no idea how to write it correctly?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 00:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783304#M249735</guid>
      <dc:creator>Realmadrid1992</dc:creator>
      <dc:date>2021-12-01T00:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with maximum length of expression in user transformation(SAS Data Integration Studio)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783313#M249738</link>
      <description>&lt;P&gt;Unsure of what your data is like, but it seems that this could help:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*FIRST POINT*/
data _null_;
    set product_table;
    .........
    /*some data step code*/
    .........
    put 'if PRODUCT =' PRODUCT $quote. ' then do;' ;
    put PROD_STATEMENT ;
    put 'end;' ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 05:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783313#M249738</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-12-01T05:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with maximum length of expression in user transformation(SAS Data Integration Studio)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783844#M250038</link>
      <description>Thanks. I solved my problem by using user %include file in data step with necessary text expression</description>
      <pubDate>Fri, 03 Dec 2021 07:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-maximum-length-of-expression-in-user-transformation/m-p/783844#M250038</guid>
      <dc:creator>Realmadrid1992</dc:creator>
      <dc:date>2021-12-03T07:20:15Z</dc:date>
    </item>
  </channel>
</rss>

