<?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 Using a retain statement with variables with over 6000 characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884237#M349321</link>
    <description>&lt;P&gt;I am trying to create a retain variables in a statement that is over 6000 characters long and getting an error - please help!&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jul 2023 18:23:32 GMT</pubDate>
    <dc:creator>gstover</dc:creator>
    <dc:date>2023-07-10T18:23:32Z</dc:date>
    <item>
      <title>Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884237#M349321</link>
      <description>&lt;P&gt;I am trying to create a retain variables in a statement that is over 6000 characters long and getting an error - please help!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 18:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884237#M349321</guid>
      <dc:creator>gstover</dc:creator>
      <dc:date>2023-07-10T18:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884238#M349322</link>
      <description>&lt;P&gt;What error are you getting? Show us the ENTIRE log for the data step in which you are using RETAIN — do not show us a partial log. Copy the log as text, paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Insert Log Icon in SAS Communities.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66171iFEC370B1DBF07B28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Insert Log Icon in SAS Communities.png" alt="Insert Log Icon in SAS Communities.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 18:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884238#M349322</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-10T18:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884240#M349323</link>
      <description>&lt;P&gt;There is no log.&amp;nbsp; Trying to order the variables on the output and there are 998 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gstover_0-1689016485367.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85701i201B915F01134F7B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gstover_0-1689016485367.png" alt="gstover_0-1689016485367.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884240#M349323</guid>
      <dc:creator>gstover</dc:creator>
      <dc:date>2023-07-10T19:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884241#M349324</link>
      <description>&lt;P&gt;What happens if you split this long list of variables across many lines?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884241#M349324</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-10T19:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884242#M349325</link>
      <description>&lt;P&gt;That error message refers to length of a single line of code. Can't exceed 6000 characters. So your Subject line is incorrect.&lt;/P&gt;
&lt;P&gt;Use multiple Length statements. They will be processed in order of appearance in the code so&lt;/P&gt;
&lt;PRE&gt;Length var1 var2 var3 8 ;
Length var15 var16 var17 $ 5;
&lt;/PRE&gt;
&lt;P&gt;is equivalent to&lt;/P&gt;
&lt;PRE&gt;Length var1 var2 var3 8 var15 var16 var17 $ 5;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I still don't see why so many people spend so much time worrying about the order of variables in a data set...&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884242#M349325</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-07-10T19:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884243#M349326</link>
      <description>&lt;P&gt;So your SAS installation doesn't want statements longer than 6000 characters, and you apparently have some statement (maybe a LENGTH statement since that's what shows in your popup window) longer than 6000 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So make multiple LENGTH statements, each no more than 6000 characters.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884243#M349326</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-07-10T19:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884244#M349327</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I still don't see why so many people spend so much time worrying about the order of variables in a data set...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think it is unnecessary and a waste of effort as well, but its a rare event when I can convince someone who is determined to order the variables in a data set to NOT do that.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884244#M349327</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-10T19:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884245#M349328</link>
      <description>&lt;P&gt;The reason for the order is because it is for a data submission that has this requirement.&lt;/P&gt;&lt;P&gt;The variables are in the dataset and need to be put out to a file in this order.&amp;nbsp; Can I use a length statement even with the variables already created?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884245#M349328</guid>
      <dc:creator>gstover</dc:creator>
      <dc:date>2023-07-10T19:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884246#M349329</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But I still don't see why so many people spend so much time worrying about the order of variables in a data set...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I do.&amp;nbsp; Because&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&amp;nbsp;I often benefit from using the double dash technique for referring to a related group of variables in a list, mostly for arrays or keep/drop lists.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Probably even more often, I want to see the related variables together in a data window, and don't want to bother making any extra effort to make them appear contiguous.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Yes, it's possible to overstress variable order, but it's not a worthless objective.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884246#M349329</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-07-10T19:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884247#M349330</link>
      <description>&lt;P&gt;The message is not about the length of a VARIABLE or even the length of the value of a variable.&lt;/P&gt;
&lt;P&gt;It is about the length of line in the file that has the code.&lt;/P&gt;
&lt;P&gt;So when you write the code to the file split the long lines into multiple lines.&amp;nbsp; SAS does not care how long the STATEMENT is, but it obviously cannot reads lines of code that have over 6000 characters (at least using whatever method you used to submit the code).&lt;/P&gt;
&lt;P&gt;But in practical terms you should not be making lines of code that is longer than about 70 to 75 characters anyway so that HUMANS can read them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also your code is using a LENGTH statement, not a RETAIN statement.&amp;nbsp; If the purpose of the RETAIN statement was just to force the ORDER then it must come BEFORE the variables are defined by a LENGTH or a SET or any other statement that would set the order, type and length of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How did you create that giant LENGTH statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you created from a source dataset then just limit the length of the lines while writing the statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for example if you have a dataset named HAVE and a metadata dataset named VARIABLES you can use the two of them to create a dataset named WANT that has the variables in the order they appear in VARIABLES with code like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
   set variables  end=eof;
   file code lrecl=75 ;
   if _n_=1 then put 'RETAIN ' @;
  put name @ ;
  if eof then put / ';' ;
run;

data want;
%include code / source2;
  set have;
run;
   &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884247#M349330</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T19:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using a retain statement with variables with over 6000 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884249#M349332</link>
      <description>&lt;P&gt;No need to make separate statements.&amp;nbsp; Just make separate lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: I don't understand why people spend so much time making datasets with variables in some random order (or some even worse order) that makes it almost impossible to look at the data.&amp;nbsp; It takes almost no effort to define the variables in a rational order.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-retain-statement-with-variables-with-over-6000/m-p/884249#M349332</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T19:56:15Z</dc:date>
    </item>
  </channel>
</rss>

