<?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: Using INTO to create a macro variable for pass-through teradata query in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555242#M9644</link>
    <description>&lt;P&gt;The list of hicno's are already distinct.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2019 22:39:48 GMT</pubDate>
    <dc:creator>kb011235</dc:creator>
    <dc:date>2019-04-30T22:39:48Z</dc:date>
    <item>
      <title>Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555209#M9628</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql noprint;



select "'"||strip(hicno)||"'"

into :hicno_list separated by ","

from monmemd;



%tera_sql_con(EDWTDP);



create table new_table as

select * from connection to teradata

(select *

from data_warehouse.MPD_FSGE_CMS_RX_DRG_EVT

where hic_nbr in ( &amp;amp;hicno_list. )

);

quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The situation is that I have a dataset in my working directory ("monmemd") from which some id's ("hicno") are queried. From there, the hicno's are used as filters in a query on another dataset that is in a teradata db ("data_warehouse.MPD_FSGE_CMS_RX_DRG_EVT"). The teradata connection is of the pass-through type, so I'm not able to join monmemd into the passthrough query. What I tried to do was to create a macro variable of the hicno's that could be used as a parameter in the teradata query, but I get the following error related to the macro variable hicno_list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"ERROR: The text expression length (65535) exceeds maximum length (65534). The text expression has been truncated to 65534 characters."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried&lt;/P&gt;&lt;PRE&gt;Options mexecsize = 500000
MSYMTABMAX = 500000
MVARSIZE = 500000;&lt;/PRE&gt;&lt;P&gt;but MVARSIZE must be between 0 and 65534 length.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The pass-through connection is super efficient compared to the direct connection. I don't want to import the entire MPD_FSGE_CMS_RX_DRG_EVT table and filter in SAS since the alternative would be more efficient.&lt;/P&gt;&lt;P&gt;Does anyone have any other ideas about how I can pass a one column table of ID's into a pass-through teradata query?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 20:37:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555209#M9628</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2019-04-30T20:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555212#M9630</link>
      <description>&lt;P&gt;Rather than a macro variable, consider creating a macro that generates the list. This is old and untested but should still work. I think it was designed for numbers so you'll need to modify it for character values. For you code you would replace &amp;amp;hicno_list with the macro call, %test(t)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;                                                                                                                                 
input key;                                                                                                                              
cards;                                                                                                                                  
1                                                                                                                                       
-1                                                                                                                                      
3                                                                                                                                       
;                                                                                                                                       
                                                                                                                                        
%macro test(dsn);                                                                                                                       
%let dsid=%sysfunc(open(&amp;amp;dsn(where=(key &amp;gt; 0))));                                                                                     
%let cnt=%sysfunc(attrn(&amp;amp;dsid,nlobsf));                                                                                                
%let num=%sysfunc(varnum(&amp;amp;dsid,key));                                                                                                  
  %do i = 1 %to &amp;amp;cnt;                                                                                                                   
   %let rc=%sysfunc(fetchobs(&amp;amp;dsid,&amp;amp;i));                                                                                                
   %let val=%sysfunc(getvarn(&amp;amp;dsid,&amp;amp;num));                                                                                              
%if &amp;amp;i ne &amp;amp;cnt %then %do;                                                                                                               
&amp;amp;val,                                                                                                                                   
%end;                                                                                                                                   
%else %do;                                                                                                                              
&amp;amp;val                                                                                                                                    
%end;                                                                                                                                   
%end;                                                                                                                                   
                                                                                                                                        
%let rc=%sysfunc(close(&amp;amp;dsid));                                                                                                         
%put dd;                                                                                                                                
%mend test;                                                                                                                             
                                                                                                                                        
data new;                                                                                                                               
new="%test(t)";                                                                                                                        
run;                                                                                                                                    
                                                                                                                                        
proc print;                                                                                                                             
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/251111"&gt;@kb011235&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;



select "'"||strip(hicno)||"'"

into :hicno_list separated by ","

from monmemd;



%tera_sql_con(EDWTDP);



create table new_table as

select * from connection to teradata

(select *

from data_warehouse.MPD_FSGE_CMS_RX_DRG_EVT

where hic_nbr in ( &amp;amp;hicno_list. )

);

quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The situation is that I have a dataset in my working directory ("monmemd") from which some id's ("hicno") are queried. From there, the hicno's are used as filters in a query on another dataset that is in a teradata db ("data_warehouse.MPD_FSGE_CMS_RX_DRG_EVT"). The teradata connection is of the pass-through type, so I'm not able to join monmemd into the passthrough query. What I tried to do was to create a macro variable of the hicno's that could be used as a parameter in the teradata query, but I get the following error related to the macro variable hicno_list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"ERROR: The text expression length (65535) exceeds maximum length (65534). The text expression has been truncated to 65534 characters."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried&lt;/P&gt;
&lt;PRE&gt;Options mexecsize = 500000
MSYMTABMAX = 500000
MVARSIZE = 500000;&lt;/PRE&gt;
&lt;P&gt;but MVARSIZE must be between 0 and 65534 length.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The pass-through connection is super efficient compared to the direct connection. I don't want to import the entire MPD_FSGE_CMS_RX_DRG_EVT table and filter in SAS since the alternative would be more efficient.&lt;/P&gt;
&lt;P&gt;Does anyone have any other ideas about how I can pass a one column table of ID's into a pass-through teradata query?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 20:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555212#M9630</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-30T20:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555225#M9631</link>
      <description>&lt;P&gt;Just for giggles did you consider ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;select distinct "'"||strip(hicno)||"'"
&lt;/PRE&gt;
&lt;P&gt;We obviously don't know your data but without the distinct predicate you could have duplicate values making the string longer than needed.&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 Apr 2019 21:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555225#M9631</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-30T21:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555228#M9634</link>
      <description>&lt;P&gt;Why not just upload the list into a temporary table in Teradata and use that table in your query?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 21:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555228#M9634</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-30T21:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555229#M9635</link>
      <description>Because a large set of SAS installations are set so you can read data but not write anything to the server.</description>
      <pubDate>Tue, 30 Apr 2019 22:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555229#M9635</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-30T22:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555231#M9637</link>
      <description>&lt;P&gt;If you really must generate a really long list of values into macro variables from data here is a method that make a series on macro variables and another separate macro variable that can be used to expand them all.&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;data _null_;
  length mvarlist value_list $32000 mvar $32;
  retain mvarlist;
  varnum+1;
  do until(length(value_list)&amp;gt;30000 or eof);
    set monmemd end=eof;
    by hicno ;
    if first.hicno then value_list=catx(',',value_list,quote(trim(hicno),"'"));
  end;
  mvar=cats('hicno_list',varnum);
  call symputx(mvar,value_list);
  mvarlist=catx(',',mvarlist,'&amp;amp;'||mvar);
  if eof then call symputx('hicno_list',mvarlist);
run;

proc sql noprint;
%tera_sql_con(EDWTDP);

create table new_table as
  select * from connection to teradata

(select *
 from data_warehouse.MPD_FSGE_CMS_RX_DRG_EVT
 where hic_nbr in ( &amp;amp;hicno_list. )
);

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;So you have HICNO_LIST1,HICNOLIST2, etc will list of values and then HICNO_LIST has &amp;amp;HICNO_LIST1,&amp;amp;HICNO_LIST22, etc.&amp;nbsp; That way you could have up to 4000*32K bytes in the IN list.&lt;/P&gt;
&lt;P&gt;Should work if the Teradata administrators don't cancel the query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 22:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555231#M9637</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-30T22:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555242#M9644</link>
      <description>&lt;P&gt;The list of hicno's are already distinct.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 22:39:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555242#M9644</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2019-04-30T22:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555243#M9645</link>
      <description>&lt;P&gt;I don't have that level of permission on our teradata server.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 22:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555243#M9645</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2019-04-30T22:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555244#M9646</link>
      <description>&lt;P&gt;Thanks for the effort, but your method runs into the same list length issue (capped at 65534 characters).&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 22:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555244#M9646</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2019-04-30T22:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555249#M9647</link>
      <description>&lt;P&gt;The code I posted will not make any macro variable longer than about 30K.&lt;/P&gt;
&lt;P&gt;Are you saying that Teradata is complaining if the code is too long?&lt;/P&gt;
&lt;P&gt;Or is PROC SQL complaining if the statement is too long?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show your log.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 23:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555249#M9647</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-30T23:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555368#M9658</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/251111"&gt;@kb011235&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the effort, but your method runs into the same list length issue (capped at 65534 characters).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show your LOG with the code submitted and the error messages.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 14:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555368#M9658</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-01T14:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555371#M9660</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/251111"&gt;@kb011235&lt;/a&gt;&amp;nbsp; did you try my approach? Did it not work?&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 14:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555371#M9660</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-01T14:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555396#M9669</link>
      <description>&lt;P&gt;I ran your code again this morning and didn't get the same error message. Yesterday, I ran your code in the immediate window where I had been testing, so I think that affected the results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm testing the rerun now and I'll let you know of the results.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 16:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555396#M9669</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2019-05-01T16:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555491#M9688</link>
      <description>&lt;P&gt;Here is the updated code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;options spool nocenter mprint symbolgen obs=max nocenter mautosource mrecall
	sasautos =('!sasroot/sasautos','/sasdata/projects1/underwriting/macros','/sasdata/prod/macros','/sasuser/bailkx4/macros') ;

proc printto log="/sasuser/&amp;amp;sysuserid./programs/scratchwork/test.log"
  print="/sasuser/&amp;amp;sysuserid./programs/scratchwork/test.lst";
  run;

/* Store data in SAS */
DATA monmemd;
   set "/sasuser/&amp;amp;sysuserid./wrk/support/monmemd/monmemd.sas7bdat";
RUN;

proc sort data = monmemd out = monmemd;
by hicno;
run;

data _null_;
  length mvarlist value_list $32000 mvar $32;
  retain mvarlist;
  varnum+1;
  do until(length(value_list)&amp;gt;30000 or eof);
    set monmemd end=eof;
    by hicno ;
    if first.hicno then value_list=catx(',',value_list,quote(trim(hicno),"'"));
  end;
  mvar=cats('hicno_list',varnum);
  call symputx(mvar,value_list);
  mvarlist=catx(',',mvarlist,'&amp;amp;'||mvar);
  if eof then call symputx('hicno_list',mvarlist);
run;

proc sql noprint;
%tera_sql_con(EDWTDP);

create table new_table as
  select * from connection to teradata

(select *
 from data_warehouse.MPD_FSGE_CMS_RX_DRG_EVT
 where hic_nbr in (&amp;amp;hicno_list.)
);

quit;

%xport(work,new_table);&lt;/PRE&gt;&lt;P&gt;Attached is the log. I deleted the list of ID's, but one thing that's interesting is right before row 71, where it says "Macro variable HICNO_LIST1 resolves to&amp;nbsp;Macro variable HICNO_LIST1 resolves to '&lt;BR /&gt;','xxxxx', 'by xxxxx')." (The x's represent hicno's.) I don't understand how "by" was added to the list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One other thing that I don't understand in the log is where it says that the errors were printed on pages.... I added a printto statement to try and get the errors to print to a specific place, but that didn't work.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 21:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555491#M9688</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2019-05-01T21:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555493#M9689</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;I didn't try your approach.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 21:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555493#M9689</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2019-05-01T21:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555511#M9690</link>
      <description>&lt;P&gt;You have&amp;nbsp;4,174,828 values of HICNO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's do a little arithmetic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How long is the average HICNO? The average would have to be at LEAST 6 characters to support over 4 million distinct values.&lt;/P&gt;
&lt;P&gt;Plus 2 for the quotes and 1 for comma.&amp;nbsp; That is over 32 Million characters just to make the list of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is totally inappropriate for this type of approach.&lt;/P&gt;
&lt;P&gt;Upload the list into the database and join in the database.&amp;nbsp; In fact keep ALL of the data in the database only pull out your summary statistics back to your SAS server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 23:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555511#M9690</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-01T23:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555515#M9691</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;There aren't 4174828 hicno's. The number of records in monmemd is 4174828, which is filtered down to 80825 distinct hicno's.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't notice until now that your code missed the other filters. Here is the updated code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;options spool nocenter mprint symbolgen obs=max nocenter mautosource mrecall
	sasautos =('!sasroot/sasautos','/sasdata/projects1/underwriting/macros','/sasdata/prod/macros','/sasuser/bailkx4/macros') ;

proc printto log="/sasuser/&amp;amp;sysuserid./programs/scratchwork/test.log"
  print="/sasuser/&amp;amp;sysuserid./programs/scratchwork/test.lst";
  run;

/* Store data in SAS */
DATA monmemd;
   set "/sasuser/&amp;amp;sysuserid./wrk/support/monmemd/monmemd.sas7bdat";
RUN;

proc sql;
create table hicno_table as
select DISTINCT strip(hicno) as hicno
from
	(select hicno
	, count(hicno) as rcd_ct
	from monmemd
	where substr(payment_date,1,4) = "2016" and adj_reason = ""
	group by hicno
	)
where rcd_ct = 12
order by hicno;
quit;

data _null_ options noprint;
  length mvarlist value_list $32000 mvar $32;
  retain mvarlist;
  varnum+1;
  do until(length(value_list)&amp;gt;30000 or eof);
    set hicno_table end=eof;
    by hicno ;
    if first.hicno then value_list=catx(',',value_list,quote(trim(hicno),"'"));
  end;
  mvar=cats('hicno_list',varnum);
  call symputx(mvar,value_list);
  mvarlist=catx(',',mvarlist,'&amp;amp;'||mvar);
  if eof then call symputx('hicno_list',mvarlist);
run;

proc sql noprint;
%tera_sql_con(EDWTDP);

create table new_table as
  select * from connection to teradata

(select *
 from data_warehouse.MPD_FSGE_CMS_RX_DRG_EVT
 where hic_nbr in (&amp;amp;hicno_list.)
);

quit;

%xport(work,new_table);&lt;/PRE&gt;&lt;P&gt;Here is the error message:&amp;nbsp;ERROR: CLI prepare error: [Teradata][ODBC Teradata Driver] SQL request with parameters exceeds maximum allowed length of 1 MB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What about wrapping the proc sql teradata step in a loop and passing the hicno_list in smaller pieces, then reassembling the results? Could that work?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 01:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555515#M9691</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2019-05-02T01:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555525#M9697</link>
      <description>&lt;P&gt;Just upload the data into Teradata. And then use it in your query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname td teradata .... DBMSTEMP=YES ;

proc sort nodupkey 
  data="/sasuser/&amp;amp;sysuserid./wrk/support/monmemd/monmemd.sas7bdat"
  out=td.hicno_table (keep=hicno)
;
  where substr(payment_date,1,4) = "2016" and missing(adj_reason);
run;

proc sql noprint;
connect using TD;

create table new_table as
  select * from connection to TD

(select *
 from data_warehouse.MPD_FSGE_CMS_RX_DRG_EVT
 where hic_nbr in (select hicno from hicno_table)
);

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 May 2019 02:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555525#M9697</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-02T02:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555979#M9739</link>
      <description>&lt;P&gt;I couldn't get this to work; the error message says that the teradata engine cannot be found.&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2019 15:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555979#M9739</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2019-05-03T15:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTO to create a macro variable for pass-through teradata query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555984#M9741</link>
      <description>&lt;P&gt;Use whatever engine your current process is using.&amp;nbsp; I would assume you are using ODBC if you don't have SAS/Access to Teradata licensed.&amp;nbsp; You are not going to get as much performance out of the SAS - Teradata connection using generic ODBC connection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can still get access using ODBC engine, but I am not sure if that supports accessing volatile tables via a libref.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try it and see.&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2019 15:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-INTO-to-create-a-macro-variable-for-pass-through-teradata/m-p/555984#M9741</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-03T15:42:43Z</dc:date>
    </item>
  </channel>
</rss>

