<?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: Proc freq does not take sql macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407236#M279382</link>
    <description>&lt;P&gt;I might have found the cause of this problem. In the library are two objects with same name: mt=view and mt=data. As the object with mt=data is empty in given enviroment, the mt=view is not. I would need to make the program understand that it needs to execute proc freq on mt=view - is there any way how to proceed? Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2017 13:01:31 GMT</pubDate>
    <dc:creator>Uknown_user</dc:creator>
    <dc:date>2017-10-25T13:01:31Z</dc:date>
    <item>
      <title>Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407172#M279369</link>
      <description>&lt;P&gt;I am trying to make proc freq understand sql macro variable. The code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let libname = DM_CMDM;

/*[...]*/&lt;BR /&gt;
/*this bit of code is working*/

proc sql noprint;

select distinct table_name

into: var1 - : var&amp;amp;nrows

from tables;

quit;


%macro loop_();

%do i = 1 %to &amp;amp;nrows;


/*working bit of code*/

proc contents data=&amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i Position noprint

out=content_&amp;amp;&amp;amp;var&amp;amp;i;

run;


/*this bit of code is not working due to data=&amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i cannot be read properly*/

ods table onewayfreqs=temp_&amp;amp;&amp;amp;var&amp;amp;i;
&lt;BR /&gt;/*this bit of code is working*/&lt;BR /&gt;proc format;&lt;BR /&gt;value $ missfmt ' ' = "Missing" other = "Not_Missing";&lt;BR /&gt;value nmissfmt . = "Missing" other = "Not_Missing";&lt;BR /&gt;run;&lt;BR /&gt;
proc freq data=&amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i; /*this causes problems*/&lt;BR /&gt;table _all_/missing;&lt;BR /&gt;format _numeric_ nmissfmt. _character_ $missfmt.;&lt;BR /&gt;run;


%end;

%mend;

%loop_()&lt;/PRE&gt;&lt;P&gt;I cannot understand why "proc contents" works and understands &amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i and "proc freqs" does not. Any suggestion how to amend the script so that it worked?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the typos, I cannot copy/paste between remote and this desktop. The problem is actually where I stated. If write the table name by hand, it works flawleslly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 10:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407172#M279369</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-10-25T10:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407177#M279370</link>
      <description>&lt;P&gt;Maybe the missing colon after &lt;/P&gt;
&lt;PRE&gt;ods table onewayfreqs=temp_&amp;amp;&amp;amp;var&amp;amp;i&lt;/PRE&gt;
&lt;P&gt;causes the problem. Posting log with options mprint, mlogic and symbolgen active will help in the bug-hunt.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 09:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407177#M279370</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-10-25T09:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407178#M279371</link>
      <description>&lt;P&gt;What is it your trying to do?&amp;nbsp; Start by doing something using Base SAS, I keep repeating this, Base SAS is &lt;U&gt;&lt;STRONG&gt;the&lt;/STRONG&gt;&lt;/U&gt; programming language, macro is not a replacement for this.&amp;nbsp; There are at least two far simpler options which jump to mind just from that code:&lt;/P&gt;
&lt;P&gt;A) Put your data together, it is rarely a good idea to keep same data in different datasets - it leads to this kind of messy hard to maintain coding:&lt;/P&gt;
&lt;PRE&gt;data total;
  set ... indsname=tmp;
  file=tmp;
run;&lt;/PRE&gt;
&lt;P&gt;As I don't know your data I can't specify the set.&amp;nbsp; &amp;nbsp;This combines data and creates a new column for the table name.&amp;nbsp; You can then write&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;very&lt;/STRONG&gt;&lt;/U&gt; simple and easy to use code:&lt;/P&gt;
&lt;PRE&gt;proc freq data=total;
  by file;
  ...
run;&lt;/PRE&gt;
&lt;P&gt;No macro, just simple inbuilt by group processing - just by using this thinking all of your code will dilute down to 10% of the orignal coding and be far easier to use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B)&amp;nbsp; You could also avoid the loop by using an inherent loop in the dataset:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set tables;
  call execute("proc freq data=&amp;amp;library.."||strip(table_name)||"; ...; run;");
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 09:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407178#M279371</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-25T09:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407180#M279372</link>
      <description>&lt;P&gt;Thanks for your reply. I REALLY do not want to work with one big data set. What I am trying to do is to take all tables from one library and run a script on them one by one. The reason for that is execution in waves (i.e. in one wave 10 tables or something like that).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that there are tables with 1 bil+ rows which will be excluded easily when using macro variable with table names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Having said that, I need to choose some other form of &amp;amp;&amp;amp;var&amp;amp;i to make the proc freq understand what table it is. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 09:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407180#M279372</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-10-25T09:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407193#M279373</link>
      <description>&lt;P&gt;There is no problem with PROC FREQ.&lt;/P&gt;
&lt;P&gt;Run next simplified code - it works fine:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let libname = sashelp;
%let i = 2;
%let var2 = class;

proc freq data=&amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i;
   table sex;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your issue is missing semicolon ( ; ) at the end od ODS TABLE statement,&lt;/P&gt;
&lt;P&gt;as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;mentiond.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 10:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407193#M279373</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-25T10:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407194#M279374</link>
      <description>&lt;P&gt;Hi, I cannot copy/paste the text of the script so I simply rewrote it and missed a ";" in here but in the original script it is present there. That is not the problem - as I mentioned if I write the libname and table name by hand, it works, even this works: &amp;amp;libname..TABLE (where TABLE is the actual name of table written by hand). Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 10:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407194#M279374</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-10-25T10:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407195#M279375</link>
      <description>&lt;P&gt;If you don't want one big dataset, then use option B.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 10:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407195#M279375</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-25T10:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407201#M279376</link>
      <description>&lt;P&gt;I do not think that option B can be used either. I tried to rewrite it as follows: data tmp; set &amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i; call execute("proc freq data=&amp;amp;libname.."strip("&amp;amp;&amp;amp;var&amp;amp;i.")||"; table _all_ / missing; format _numeric_ nmissfmt. _character_ $missfmt.; run;"); run; This produced empty output with just headers and no records in it...&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 11:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407201#M279376</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-10-25T11:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407202#M279377</link>
      <description>&lt;P&gt;Please re-read the code.&amp;nbsp; From your first post you have a dataset called table_names which contains, I assume, the tables you want to proc freq.&amp;nbsp; This is the basis for the data _null_ step:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set tables;   /* For each row in dataset tables generate the below code */
  call execute("proc freq data=&amp;amp;library.."||strip(table_name)||"; ...; run;");&lt;BR /&gt;  /* Use table_name from tables dataset as the generic part of the code */
run;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Do bear in mind that I am writing code completely blind here as I have no idea what your data looks like.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 11:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407202#M279377</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-25T11:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407204#M279378</link>
      <description>&lt;P&gt;Perhaps you don't want a big data set FILE, but&amp;nbsp; maybe a data set VIEW would serve your needs, without adding to disk space requirements, or extra processing time:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data total /view=total;
  set ... indsname=tmp;
  file=tmp;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then use a&amp;nbsp;"BY FILE" statement&amp;nbsp; as per &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;'s suggestion.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 11:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407204#M279378</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-25T11:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407218#M279379</link>
      <description>&lt;P&gt;I appreciate all of your suggestions. This in fact might be more efficient, however, I would have to rewrite the whole piece of code to make it work (there are further steps which I did not post thought) and none of these posts has actually answered the question. I simply need to the proc freq understand &amp;amp;&amp;amp;var&amp;amp;i and do not know how to do that. Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 11:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407218#M279379</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-10-25T11:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407225#M279380</link>
      <description>&lt;P&gt;You need to post the log, we cannot guess what the run looks like - just the bit around the proc freq, including any let statements etc.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 12:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407225#M279380</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-25T12:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407227#M279381</link>
      <description>&lt;P&gt;Insert %put statements at proper places to get a feel what your macro does; also use options mprint mlogic symbolgen;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other posts have already given evidence that proc freq will "understand" an indirect macro variable resolution.&lt;/P&gt;
&lt;P&gt;(actually, it's not proc freq, it's just the macro preprocessor resolving macro variables)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let libname = WORK;

data work.table1;
set sashelp.class;
run;

data work.table2;
set sashelp.class;
run;

data tables;
input table_name $;
cards;
table1
table2
;
run;

%let nrows=2;

proc sql noprint;
select distinct table_name
into: var1 - : var&amp;amp;nrows
from tables;
quit;


%macro loop_();

%do i = 1 %to &amp;amp;nrows;

/*working bit of code*/
proc contents data=&amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i Position noprint
out=content_&amp;amp;&amp;amp;var&amp;amp;i;
run;

/*this bit of code is not working due to data=&amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i cannot be read properly*/

ods table onewayfreqs=temp_&amp;amp;&amp;amp;var&amp;amp;i;

/*this bit of code is working*/
proc format;
value $ missfmt ' ' = "Missing" other = "Not_Missing";
value nmissfmt . = "Missing" other = "Not_Missing";
run;

proc freq data=&amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i; /*this causes problems*/
table _all_/missing;
format _numeric_ nmissfmt. _character_ $missfmt.;
run;

%end;

%mend;

%loop_()&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and you will see that the core of your macro as posted DOES work, and that there is NO problem with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;libname..&amp;amp;&amp;amp;var&amp;amp;i&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the proc freq. So your code as posted has to have essential differences to the code you really run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 12:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407227#M279381</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-25T12:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407236#M279382</link>
      <description>&lt;P&gt;I might have found the cause of this problem. In the library are two objects with same name: mt=view and mt=data. As the object with mt=data is empty in given enviroment, the mt=view is not. I would need to make the program understand that it needs to execute proc freq on mt=view - is there any way how to proceed? Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 13:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407236#M279382</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-10-25T13:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407246#M279383</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/95386"&gt;@Uknown_user&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I might have found the cause of this problem. In the library are two objects with same name: mt=view and mt=data. As the object with mt=data is empty in given enviroment, the mt=view is not. I would need to make the program understand that it needs to execute proc freq on mt=view - is there any way how to proceed? Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Basically, that's an invalid state. SAS does not allow a view and a dataset of the same name in the same library at any given time.&lt;/P&gt;
&lt;P&gt;This program will fail when attempting to create the views:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.table1;
set sashelp.class;
run;

data work.table2;
set sashelp.class;
run;

data work.table1/view=work.table1;
set sashelp.class;
run;

data work.table2/view=work.table2;
set sashelp.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 13:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407246#M279383</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-25T13:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407247#M279384</link>
      <description>&lt;P&gt;You should check why tere are the two objects with same name but different type (data/view).&lt;/P&gt;
&lt;P&gt;May be the empty data is a result of a bug or created unintentionally ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are convinced that there must be both types with same name, you need&amp;nbsp;&lt;/P&gt;
&lt;P&gt;add to your macro checking the member type and how many observations there are,&lt;/P&gt;
&lt;P&gt;but the - which of them is the right to use, if both - the data and the view - have real observations?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 13:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407247#M279384</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-25T13:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407248#M279385</link>
      <description>&lt;P&gt;I have managed to make the script understand that it will only be executed for non-empty tables (views in my case). Now the whole piece of code works. Those of you that stated the script is fine were right, I just needed to exclude empty tables from the library and then run it. Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 13:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407248#M279385</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-10-25T13:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407249#M279386</link>
      <description>&lt;P&gt;you are right, there were two chars of the whole string name different but I did not notice that before. In the initial stage I accidentely included empty tables which was consequently fixed.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 13:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407249#M279386</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2017-10-25T13:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq does not take sql macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407260#M279387</link>
      <description>&lt;P&gt;Sounds like your problem was not with the macro variable generation and usage, but in the selection of which members to include in the list.&lt;/P&gt;
&lt;P&gt;But you can simplify the way that you use SQL to generate the list of macro variables.&lt;/P&gt;
&lt;P&gt;You do not need to know in advance the number of variables that it creates.&amp;nbsp; Instead let PROC SQL tell you how many it finds.&lt;/P&gt;
&lt;P&gt;Just leave the upper bound unspecified and save the automatic macro variable SQLOBS to see how many rows/macro variables were generated.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select distinct table_name
  into :var1-
  from tables
;
%let nrows=&amp;amp;sqlobs ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are running a really old version of SAS then you might need add an upper bound, but it just needs to be at least as large as the maximum number of rows you could get. SQL will only create the number of macro variables it actually needs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select distinct table_name
  into :var1-:var99999
  from tables
;
%let nrows=&amp;amp;sqlobs ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 13:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-does-not-take-sql-macro-variable/m-p/407260#M279387</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-25T13:36:08Z</dc:date>
    </item>
  </channel>
</rss>

