<?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: Macro Variable Length Limit in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664176#M198393</link>
    <description>&lt;P&gt;Yups, Its an update to accomplish Incremental loading. But Unique key "Name" has multiple entries based on financial year, amout...etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scenarios is like,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Main_Table&lt;/P&gt;&lt;P&gt;Year&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Amount&lt;/P&gt;&lt;P&gt;2019 ABCDS6008K 500&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INC_Table&lt;/P&gt;&lt;P&gt;Year&amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Amount&lt;/P&gt;&lt;P&gt;2019 ABCDS6008K &amp;nbsp;500&lt;/P&gt;&lt;P&gt;2020&amp;nbsp;ABCDS6008K 1000&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, 23 Jun 2020 09:02:23 GMT</pubDate>
    <dc:creator>robin24</dc:creator>
    <dc:date>2020-06-23T09:02:23Z</dc:date>
    <item>
      <title>Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/663837#M198243</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;Hope you all are doing great and keeping yourself safe amid Covid-19.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me, I am trying to implement Incremental loading: Using below code but getting error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;INC_TABLE is having approx 10 lakh names.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;FONT color="#FF0000"&gt;ERROR: The length of the value of the macro variable KEYNAME (65540) exceeds the maximum length (65534). The value has been truncated to 65534 characters.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000"&gt;Please suggest the wayout to get macro varaible keyname solved, or way the to identify same in where clause under PROC IMSTAT&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Proc sql noprint;&lt;/DIV&gt;&lt;DIV&gt;select distinct compress("'"||NAME||"'") into: KeyName separated by&amp;nbsp; ',' from VALIBLA.INC_TABLE;&lt;/DIV&gt;&lt;DIV&gt;quit;&lt;/DIV&gt;&lt;DIV&gt;proc imstat;&lt;/DIV&gt;&lt;DIV&gt;table VALIBLA.MAIN_TABLE;&lt;/DIV&gt;&lt;DIV&gt;where NAME in (&amp;amp;KeyName);&lt;/DIV&gt;&lt;DIV&gt;deleterows/purge;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc imstat;&lt;/DIV&gt;&lt;DIV&gt;table MAIN_TABLE;&lt;/DIV&gt;&lt;DIV&gt;set INC_TABLE/drop;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;save path="/hps/" replace;&lt;/DIV&gt;&lt;DIV&gt;quit;&lt;/DIV&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;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Robin&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2020 12:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/663837#M198243</guid>
      <dc:creator>robin24</dc:creator>
      <dc:date>2020-06-21T12:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/663840#M198245</link>
      <description>Proc sql;&lt;BR /&gt;Create table inc_names as select distinct name from inc_ table;&lt;BR /&gt;Create table main_forimstat as select * from main_table where name in ( select name from inc_names);&lt;BR /&gt;Quit;&lt;BR /&gt;</description>
      <pubDate>Sun, 21 Jun 2020 13:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/663840#M198245</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-21T13:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/663841#M198246</link>
      <description>&lt;P&gt;You cannot change the maximum length of a macro variable, it is part of how the macro processor is designed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is it that you are actually trying to do?&amp;nbsp; It kind of looks like you want to load data from one table but exclude ids that exist in another table.&amp;nbsp; Why not just make a view that does the join and load from that?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create view to_load as 
 select * from  VALIBLA.MAIN_TABLE
&amp;nbsp;&amp;nbsp;&amp;nbsp;where&amp;nbsp;name&amp;nbsp;not&amp;nbsp;in&amp;nbsp;(select&amp;nbsp;name&amp;nbsp;from&amp;nbsp;VALIBLA.INC_TABLE)
&amp;nbsp;;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So now just load TO_LOAD into VA instead of MAIN_TABLE.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2020 13:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/663841#M198246</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-21T13:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/663847#M198249</link>
      <description>&lt;P&gt;You are abusing the macro processor for something it's not meant to do. Create a view with a sub-select, and use that in proc imstat.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2020 16:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/663847#M198249</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-21T16:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664080#M198350</link>
      <description>&lt;P&gt;Instead of loading 10 lakh names into macro variable, why not load in a hash table and use lookup to perform this? I believe you can check if your data fits into hash table based on your memory and decide this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My personal preference is to avoid "select * " followed by "not in".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 22:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664080#M198350</guid>
      <dc:creator>Nihanta</dc:creator>
      <dc:date>2020-06-22T22:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664148#M198381</link>
      <description>&lt;P&gt;Thanks Nihanta, KurtBremser, Tom, Smantha.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your kind help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My requirement is to Delete rows from Main_Table which are identified in INC_Table through column "Name"&lt;/P&gt;&lt;P&gt;As Main_Table is on LASR server, need to perform this task using PROC IMSTAT. And after which I have to append all records from INC_Table to Main_Table (Which is simple to do so).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest the way out:&lt;/P&gt;&lt;P&gt;1. If I can get alternate of macro variable where length limit is exceeded.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Also please suggest how same can be used&amp;nbsp; in where clause under PROC IMSTAT. (how view is used if created) As syntax error blocks the task further.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Robin Sharma&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Jun 2020 06:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664148#M198381</guid>
      <dc:creator>robin24</dc:creator>
      <dc:date>2020-06-23T06:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664160#M198385</link>
      <description>&lt;P&gt;After working through the documentation for IMSTAT, I suggest the following:&lt;/P&gt;
&lt;P&gt;Add a variable named _where_ to your update dataset, and create a WORK table with it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data INC_TABLE;
set VALIBLA.INC_TABLE;
_where_ = "name ='" !! strip(name) !! "'";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now use that in an UPDATE statement in IMSTAT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc imstat data=VALIBLA.MAIN_TABLE;
update data=INC_TABLE;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have no idea if that works, it's just what my interpretation of the documentation would let me try; I have no LASR server at hand, so I cannot test it.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 07:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664160#M198385</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-23T07:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664171#M198390</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;Thanks for your kind support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to perform two steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1st Step: Delete records from Main_Table which is on LASR server and contains data for a BI report. Here records which need to be deleted must be identified from INC_Table through column "name".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Challenge:&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;1.Macro variable "KeyName" performing perfect for small size INC_Table but failing large INC_Table and giving error of limited length characters.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;2. Sub queries do not work with where clause under PROC IMSTAT Procedure.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Proc sql noprint;&lt;/DIV&gt;&lt;DIV&gt;select distinct compress("'"||NAME||"'") into: KeyName separated by&amp;nbsp; ',' from VALIBLA.INC_TABLE;&lt;/DIV&gt;&lt;DIV&gt;quit;&lt;/DIV&gt;&lt;DIV&gt;proc imstat;&lt;/DIV&gt;&lt;DIV&gt;table VALIBLA.MAIN_TABLE;&lt;/DIV&gt;&lt;DIV&gt;where NAME in (&amp;amp;KeyName);&lt;/DIV&gt;&lt;DIV&gt;deleterows/purge;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;2nd Step:&amp;nbsp; Append records in Main_Table from INC_Table (Its simple by below step and no challenges in it).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc imstat;&lt;/DIV&gt;&lt;DIV&gt;table MAIN_TABLE;&lt;/DIV&gt;&lt;DIV&gt;set INC_TABLE/drop;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Jun 2020 08:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664171#M198390</guid>
      <dc:creator>robin24</dc:creator>
      <dc:date>2020-06-23T08:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664174#M198392</link>
      <description>&lt;P&gt;Since you remove and append the same keys (names), it is effectively an update. Unless your keys are not unique.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 08:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664174#M198392</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-23T08:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664176#M198393</link>
      <description>&lt;P&gt;Yups, Its an update to accomplish Incremental loading. But Unique key "Name" has multiple entries based on financial year, amout...etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scenarios is like,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Main_Table&lt;/P&gt;&lt;P&gt;Year&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Amount&lt;/P&gt;&lt;P&gt;2019 ABCDS6008K 500&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INC_Table&lt;/P&gt;&lt;P&gt;Year&amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Amount&lt;/P&gt;&lt;P&gt;2019 ABCDS6008K &amp;nbsp;500&lt;/P&gt;&lt;P&gt;2020&amp;nbsp;ABCDS6008K 1000&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, 23 Jun 2020 09:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664176#M198393</guid>
      <dc:creator>robin24</dc:creator>
      <dc:date>2020-06-23T09:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Length Limit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664224#M198397</link>
      <description>&lt;P&gt;First, I would advise you to test my suggestion with some simple made-up data, so you can verify if my idea works at all.&lt;/P&gt;
&lt;P&gt;Next, you need to expand the _where_ variable in the update dataset so that it identifies unique observations:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data INC_TABLE;
set VALIBLA.INC_TABLE;
length _where_ $200;
_where_ = "name = '" !! strip(name) !! "' and year = " !! put(year,z4.) !! " and amount = " !! put(amount,best.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jun 2020 09:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Length-Limit/m-p/664224#M198397</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-23T09:27:16Z</dc:date>
    </item>
  </channel>
</rss>

