<?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: Creating macro variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280935#M59051</link>
    <description>&lt;P&gt;Your variable value already includes the quotation marks? You can include a space after your comma in the separated by clause.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically to create a macro variable list from a character value I'll use the following code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select quote(name) into :name_list separated by ", "
from sashelp.class;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Jun 2016 22:44:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-06-28T22:44:03Z</dc:date>
    <item>
      <title>Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280929#M59050</link>
      <description>&lt;P&gt;I have bunch of character values that I need to use to filter data. Below is my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;distinct&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; abc&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;into&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; :def separated by &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;","&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; work.table1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; abc &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;is&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;not&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; null;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/* making a macro */&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'test'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;def."&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;Below is what I get.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'C0003923','00003953','C0003952','00004014','00003931','C0003930','00004821','00004426','00004427','C0004425','00&lt;/P&gt;&lt;P&gt;004429','00004430','C0004428','00004621','00001953','00001954','C0001952','00005850','00005851','C0005849','C0002034','0&lt;/P&gt;&lt;P&gt;2 The SAS System 10:26 Tuesday, June 28, 2016&lt;/P&gt;&lt;P&gt;0002035','C0002048','00002049','C0002306','C0002658',&lt;STRONG&gt;'00002659'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;WARNING: The quoted string currently being processed has become more than 262 characters long. You might have unbalanced quotation&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;marks.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0002035','C0002048','00002049','C0002306','C0002658',&lt;STRONG&gt;'00002659'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;'00000302','00000301','C0000300','00000418','00000417','C0000416','00002145',....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, it does not put "," after the value '00002659' I know it has something to do with the length of the string. but do not know what to do with it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 21:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280929#M59050</guid>
      <dc:creator>sasmom</dc:creator>
      <dc:date>2016-06-28T21:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280935#M59051</link>
      <description>&lt;P&gt;Your variable value already includes the quotation marks? You can include a space after your comma in the separated by clause.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically to create a macro variable list from a character value I'll use the following code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select quote(name) into :name_list separated by ", "
from sashelp.class;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2016 22:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280935#M59051</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-28T22:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280938#M59052</link>
      <description>&lt;P&gt;Also, the data _null_ step is redundant at this point, it's reassigning the value of DEF to TEST, which doesn't serve much of a purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 22:45:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280938#M59052</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-28T22:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280944#M59053</link>
      <description>&lt;P&gt;The data step does nothing useful and it is probably what is generating message about have a long quoted string since you coded "&amp;amp;def". &amp;nbsp;If you want to see the values in the log use %PUT statement, no needs for wrapping the value in double quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select distinct abc
    into :def separated by ","
    from work.table1
    where abc is not null
  ;
%put NOBS = &amp;amp;sqlobs ;
%put LENGTH = %length(&amp;amp;def) ;

  create table subset as
    select * 
    from table2
    where abc in (&amp;amp;def)
  ;

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a limit to the length of a macro variable (65K) and it is acutally longer than the limit for the length of a data set character variable (32K). &amp;nbsp;The truncation might be caused by the use of the data step. &amp;nbsp;But if your list of values is that long then you might not use this method as your list only needs to get twice as long to be too long to store in a single macro variable. &amp;nbsp;Looks like your values are all 8 characters (plus 2 single quotes and a comma) so 11 characters per value. &amp;nbsp;So you the maximum number of values you could put into a macro variable is less 6,000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not just use the values directly from the TABLE1 instead of making a macro variable?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  create table subset as
    select * 
    from table2
    where abc in (select abc from table1 where abc is not null)
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2016 23:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280944#M59053</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-06-28T23:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280953#M59054</link>
      <description>&lt;P&gt;Hi Tom, thanks for your reply. Below is what my data looks like in the work.table1. Some rows do not have values that's why I am saying where abc is not null. I am trying to put all of them in one string. In your reply above, I could not figure out where s table2 coming from.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;'00004014','00003931','C0003930','00004821'&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;'00004426','00004427','C0004425'&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;'00000601','C0000600'&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;'00003027','00000603','C0000602'&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 29 Jun 2016 01:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280953#M59054</guid>
      <dc:creator>sasmom</dc:creator>
      <dc:date>2016-06-29T01:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280954#M59055</link>
      <description>&lt;P&gt;You're using the values in the macro variable to filter another query, correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table2 is the table in the query where you would use the macro variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, rather than create a macro variable you could use a subquery. Given your data structure that isn't possible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's almost too bad that you have quotations and comma's in your variables already, that makes the issue harder. Did you create those variables? If so, is it possible to back up a step and do it differently?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 01:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280954#M59055</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-29T01:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280955#M59056</link>
      <description>&lt;P&gt;Yes, I am planning to use the macro variable to filter data in another query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data came to me as I showed you. with the quotes and commas. There are 500+ lines with that kind of values. I can remove quotes and commas and edit the table so there would be one value for ABC in each row but that means 500+ rows will be converted to 5000+, which fine but it will take a lot of work to seperate them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you think that is the only resolution?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 01:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280955#M59056</guid>
      <dc:creator>sasmom</dc:creator>
      <dc:date>2016-06-29T01:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280956#M59057</link>
      <description>&lt;P&gt;No. Your original query is fine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select distinct abc
into :def separated by ", "
from work.table1
where not missing(abc);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your data _null_ step is not required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using the macro variable DEF&amp;nbsp;as is.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;DEF.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 01:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280956#M59057</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-29T01:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280969#M59060</link>
      <description>&lt;P&gt;It is not hard to convert your TABLE1 into a normal looking table. &amp;nbsp;Let's make an example using the values you posted.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1 ;
  input abc $70. ;
cards; 
 
'00004014','00003931','C0003930','00004821'
 
 
 
'00004426','00004427','C0004425'
 
'00000601','C0000600'
'00003027','00000603','C0000602'
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now let's convert it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fixed ;
  set table1;
  length value $8 ;
  do i=1 to countw(abc,",'");
    value = scan(abc,i,",'");
    output;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you could use the table in a query. &amp;nbsp;Let's assume you have TABLE2 that looks like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table2 ;
  length id 8 value $8 ;
  input id value ;
cards;
1 00004014
2 00003931
3 C0003930
4 00004821
5 00004426
6 00004427
7 C0004425
8 XXXXYYYY
9 00001111
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can use FIXED to subset TABLE2 in many ways.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
  create table subset1 as 
    select * 
    from table2 
    where value in (select value from fixed)
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data subset2 ;
   merge table2 (in=in1) fixed(in=in2);
   by value;
   if in1 and in2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or using your macro varible method (remember this won't work if you have more that about 5,950 distinct values).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
  select distinct quote(trim(value))
    into :list separated by ','
    from fixed
  ;

  create table subset3 as
    select *
    from table2
    where value in (&amp;amp;list)
  ;
quit;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 02:54:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/280969#M59060</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-06-29T02:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281212#M59074</link>
      <description>&lt;P&gt;Thanks Tom.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not had a chance to try out your method to fix the table. The table, that has the column that I sent, has 20&amp;nbsp;additinal fields/columns. There are 500+ rows.&amp;nbsp;&amp;nbsp;Would your method work for that table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 18:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281212#M59074</guid>
      <dc:creator>sasmom</dc:creator>
      <dc:date>2016-06-29T18:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281216#M59076</link>
      <description>&lt;P&gt;Given your macro variable only deals with one column you can drop the remaining columns and the number of observations is not relevant. 500 rows is trivial to SAS.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 18:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281216#M59076</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-29T18:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281230#M59079</link>
      <description>&lt;P&gt;Thanks a lot Reez and Tom. I can not believe how easily it seperated the values for ABC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IT WORKED.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 19:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281230#M59079</guid>
      <dc:creator>sasmom</dc:creator>
      <dc:date>2016-06-29T19:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281299#M59086</link>
      <description>&lt;P&gt;I thought it was all set but I just noticed that the macro DEF does not put a "," after one of the values. so, back to square one. This happens even after I seperated ABC values. The reason I need to create macro to use to filter in another query is that query is a pass through query where I can not use the local table that has ABC values. I am so sorry for keep coming back.&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;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;distinct&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; quote(abc,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"'"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;into&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; :def separated by &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;','&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; table1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; abc &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;is&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;not&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; null;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;def.;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'C0001988','C0002048','C0002063','C0002144','C0002244','C0002246','C0002272','C0002286','C0002526','C0003232','C00&lt;/P&gt;&lt;P&gt;03837','C0003930','C0004425','C0004428','C0004917','C0004920','C0005011',&lt;STRONG&gt;'C0006466'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;'00000301','00000302','00000417','00000418','00000601','00000603','00000887','00000888','00000896','00001113','00001114','00001116',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 22:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281299#M59086</guid>
      <dc:creator>sasmom</dc:creator>
      <dc:date>2016-06-29T22:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281300#M59087</link>
      <description>&lt;P&gt;Can you double check that record in the data to verify it was parsed out properly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 22:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281300#M59087</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-29T22:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281310#M59089</link>
      <description>&lt;P&gt;that was my first reaction. Below is what it looks like in the table. Nothing different than other numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;00003027&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C0000602&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;00001259&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C0001258&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;C0006466&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;00002049&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C0002048&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;00002064&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C0002063&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 29 Jun 2016 23:08:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281310#M59089</guid>
      <dc:creator>sasmom</dc:creator>
      <dc:date>2016-06-29T23:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281314#M59090</link>
      <description>&lt;P&gt;I really don't expect proc sql to generate this type of error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might be an error in view the results in the output window. Does it work in the query?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 23:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/281314#M59090</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-29T23:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/282210#M59166</link>
      <description>&lt;P&gt;Hi Reeza, sorry I have not replied for almost a week. I was on a break. I have not had a chance to varify the results yet. I will reply again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2016 16:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-macro-variable/m-p/282210#M59166</guid>
      <dc:creator>sasmom</dc:creator>
      <dc:date>2016-07-05T16:59:02Z</dc:date>
    </item>
  </channel>
</rss>

