<?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: List All Macro Variables Created in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122165#M25046</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, now here's the exact way.&amp;nbsp; Insert into your DO loop, just before the END:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call execute('%put month' || trim(left(put(i,3.))) || ' is &amp;amp;month' || trim(left(put(i,3.))) || ';');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Aug 2013 01:14:42 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2013-08-27T01:14:42Z</dc:date>
    <item>
      <title>List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122158#M25039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tend to stay away from macro variables, but sometimes you just have to....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create "x" number of macro varaibles with this loop:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt; &lt;P&gt;DO I=1 TO months by 1; &lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;call symput("month"||trim(left(put(i,3.))),put(intnx(months',startdate,i-1,'E'),date9.));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;END;&amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there something simple that I can use to list the contents of all the variables created?&amp;nbsp; Usually&lt;/P&gt;&lt;P&gt;I just use a "%put varname", but that won't work in this case because I don't know how many&lt;/P&gt;&lt;P&gt;variables are created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 16:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122158#M25039</guid>
      <dc:creator>OS2Rules</dc:creator>
      <dc:date>2013-08-26T16:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122159#M25040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is %PUT _ALL_ what you're looking for?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000206943.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000206943.htm"&gt;SAS(R) 9.2 Macro Language: Reference&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 16:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122159#M25040</guid>
      <dc:creator>Tim_SAS</dc:creator>
      <dc:date>2013-08-26T16:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122160#M25041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&amp;nbsp;&amp;nbsp; select * from dictionary.macros; quit; Will show all of the macro variables. Add an appropriate where to look for Name starting with "month" should get you there.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 16:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122160#M25041</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-08-26T16:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122161#M25042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm actually using %put _global_ which gives me a shorter list, but I was looking for something that&lt;/P&gt;&lt;P&gt;would only list the macro variables created by the loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 16:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122161#M25042</guid>
      <dc:creator>OS2Rules</dc:creator>
      <dc:date>2013-08-26T16:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122162#M25043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To generalize you could save a copy of the dictionary table before the block of code you want to test and then pull the differences after the code block.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%symdel x1 ;&lt;/P&gt;&lt;P&gt;%symdel x2 ;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt; create table save as select * from dictionary.macros ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%let x1=x1;&lt;/P&gt;&lt;P&gt;%let x2=x2;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;/P&gt;&lt;P&gt; select * from dictionary.macros&lt;/P&gt;&lt;P&gt; where scope='GLOBAL'&lt;/P&gt;&lt;P&gt; except select * from save&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 16:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122162#M25043</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-08-26T16:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122163#M25044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another option is to write the macro names to a dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 17:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122163#M25044</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2013-08-26T17:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122164#M25045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A simple version that may do what you want:&amp;nbsp; %put _user_;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 17:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122164#M25045</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-08-26T17:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122165#M25046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, now here's the exact way.&amp;nbsp; Insert into your DO loop, just before the END:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call execute('%put month' || trim(left(put(i,3.))) || ' is &amp;amp;month' || trim(left(put(i,3.))) || ';');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 01:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122165#M25046</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-08-27T01:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122166#M25047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;do x=1 by 1 until(done);&lt;/P&gt;&lt;P&gt;set sashelp.class end=done;&lt;/P&gt;&lt;P&gt;call symputx( cats('name',x) , name );&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;call symputx( 'name0' , x );&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro loopd;&lt;/P&gt;&lt;P&gt;%do x=1 %to &amp;amp;name0;&lt;/P&gt;&lt;P&gt;%put &amp;amp;&amp;amp;name&amp;amp;x;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%loopd&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 13:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/122166#M25047</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2013-08-27T13:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/609754#M177525</link>
      <description>&lt;P&gt;&lt;EM&gt;Editor's Note: Lots of helpful and useful suggestions in this thread.&amp;nbsp; Thanks to those who commented. This one leverages the&amp;nbsp; GLOBAL macro&amp;nbsp; information and then shows how to&amp;nbsp; specifically locate the subset of variables of interest.&amp;nbsp; Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/302481"&gt;@paulrichmay&lt;/a&gt;&amp;nbsp;.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;This code worked for me.&amp;nbsp; Just pulls the data set where SAS stores the macro variables.&amp;nbsp; Restricting to 'GLOBAL' drops the 'ATUOMATIC' vars created by SAS.&amp;nbsp; Same for the if statements.&amp;nbsp; Those can be dropped depending on what you've named your variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data macro_vars;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set SASHELP.VMACRO;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;where scope = 'GLOBAL';&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if substr(name, 1, 1) = '_' then delete;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if substr(name, 1, 3) in ('SAS', 'SQL', 'SYS') then delete;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;drop scope offset;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 22:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/609754#M177525</guid>
      <dc:creator>paulrichmay</dc:creator>
      <dc:date>2023-12-08T22:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: List All Macro Variables Created</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/911919#M359557</link>
      <description>&lt;P&gt;Correct!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was looking for the same and found it.&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;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 07:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-All-Macro-Variables-Created/m-p/911919#M359557</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-01-18T07:35:02Z</dc:date>
    </item>
  </channel>
</rss>

