<?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 SQL macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313273#M270795</link>
    <description>&lt;P&gt;The DATA step that you wrapped around your macro %DO loop is not doing anything and should be removed. &amp;nbsp;If you want the data in a dataset then just skip the macro variable and have PROC SQL create the dataset for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the goal is to use macro logic to pull names one by one out of the list in the macro variable then&amp;nbsp;just use a normal iterative %DO loop.&amp;nbsp;Note that PROC SQL will tell you how many records it processed with the macro variable SQLOBS so you can set the upperbound of your %DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select memName
    into  : dset separated by '~'
    from dictionary.tables
    where libname='MYDATA' and memtype='DATA'
  ;
%let ndset=&amp;amp;sqlobs;
quit;

%do i=1 %to &amp;amp;ndset;
  %let MANUAL_FILES = %scan(&amp;amp;DSET,&amp;amp;i,~);
  %* Do something here ;
  %put &amp;amp;=i &amp;amp;=manual_files ;
%end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Nov 2016 21:44:02 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2016-11-21T21:44:02Z</dc:date>
    <item>
      <title>PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313251#M270789</link>
      <description>&lt;P&gt;Hi SAS USers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MANUAL_FILES is not being assigned with DSET values , It is coming as blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below macro i am collecting all datasets &amp;amp; combining them by tilda delimiter in DSET &amp;amp; splitting them in&amp;nbsp;&lt;SPAN&gt;UNIX_FILES Dataset &amp;amp; trying to read one by one in&amp;nbsp;MANUAL_FILES macro variable.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO INIT_PULL;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;libname mydata '/unixpath/';&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select memName into:DSET separated by '~'&lt;BR /&gt;from dictionary.tables&lt;BR /&gt;where libname='MYDATA' and memtype='DATA';&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;%PUT &amp;amp;DSET;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA UNIX_FILES;&lt;BR /&gt;Length MANUAL_FILES $32767;&lt;BR /&gt;%LET i=1;&lt;BR /&gt;%do %while (&amp;amp;i &amp;lt;= (%length(compress(&amp;amp;DSET,~,k))) +1);&lt;BR /&gt;%let MANUAL_FILES = %scan(&amp;amp;DSET,&amp;amp;i,~);&lt;BR /&gt;%let i = %eval(&amp;amp;i+1);&lt;BR /&gt;%end;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MEND INIT_PULL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%INIT_PULL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 20:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313251#M270789</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2016-11-21T20:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313261#M270790</link>
      <description>&lt;P&gt;I don't understand what your second step is trying to accomplish.&lt;/P&gt;
&lt;P&gt;Can you explain in plain language?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313261#M270790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-21T21:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313262#M270791</link>
      <description>&lt;P&gt;Pay attention - is this a typo ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;select memName into&lt;/SPAN&gt;&lt;IMG class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" border="0" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;SPAN&gt;&lt;FONT color="#FF0000"&gt;SET&lt;/FONT&gt; separated by '~'&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;%PUT &amp;amp;DSET;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(and what is the smily comes for ?)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313262#M270791</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-21T21:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313265#M270792</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel﻿&lt;/a&gt;&amp;nbsp;That's the forum converting the text. Colon Capital D -&amp;gt; &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313265#M270792</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-21T21:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313269#M270793</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It means that original text was (I just aded a blank seperator)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;select memName&lt;STRONG&gt; into : D&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;SET&lt;/STRONG&gt; separated by '~'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313269#M270793</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-21T21:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313272#M270794</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thats ":D" came as smiley , but i was trying to move collect all the datasets into a variable called DSET seperated by :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;: &amp;nbsp;this datasetep i am using it for looping &amp;amp; splitting as i have to pass one by one datasets &amp;amp; moving into a macro variable manual_files for furthur process. Manual_file is not getting resolved. Not sure if it is &amp;amp;DSET ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DATA UNIX_FILES;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Length MANUAL_FILES $32767;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%LET i=1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%do %while (&amp;amp;i &amp;lt;= (%length(compress(&amp;amp;DSET,~,k))) +1); &amp;nbsp; &amp;nbsp;(" I created DSET in previous step which has around 30 datasets &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; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sepeated by tilda &amp;nbsp;"~")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%let MANUAL_FILES = %scan(&amp;amp;DSET,&amp;amp;i,~);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%let i = %eval(&amp;amp;i+1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313272#M270794</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2016-11-21T21:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313273#M270795</link>
      <description>&lt;P&gt;The DATA step that you wrapped around your macro %DO loop is not doing anything and should be removed. &amp;nbsp;If you want the data in a dataset then just skip the macro variable and have PROC SQL create the dataset for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the goal is to use macro logic to pull names one by one out of the list in the macro variable then&amp;nbsp;just use a normal iterative %DO loop.&amp;nbsp;Note that PROC SQL will tell you how many records it processed with the macro variable SQLOBS so you can set the upperbound of your %DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select memName
    into  : dset separated by '~'
    from dictionary.tables
    where libname='MYDATA' and memtype='DATA'
  ;
%let ndset=&amp;amp;sqlobs;
quit;

%do i=1 %to &amp;amp;ndset;
  %let MANUAL_FILES = %scan(&amp;amp;DSET,&amp;amp;i,~);
  %* Do something here ;
  %put &amp;amp;=i &amp;amp;=manual_files ;
%end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313273#M270795</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-11-21T21:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313274#M270796</link>
      <description>&lt;P&gt;The data step is neither looping or splitting. Since the macro logic is not generating any actual SAS code here is your full data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA UNIX_FILES;
Length MANUAL_FILES $32767;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So it will make one observation dataset with one empty string variable.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313274#M270796</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-11-21T21:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313275#M270797</link>
      <description>&lt;P&gt;Then, macro is not needed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname mydata '/unixpath/';&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select memName into&lt;IMG class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" border="0" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;SET separated by '~'&lt;BR /&gt;from dictionary.tables&lt;BR /&gt;where libname='MYDATA' and memtype='DATA';&lt;BR /&gt;Quit;&lt;/P&gt;
&lt;P&gt;%PUT &amp;amp;DSET;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA UNIX_FILES;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Length MANUAL_FILES $32767;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;do i=1 to countw("&lt;SPAN&gt;&amp;amp;DSET"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;, '~');&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file_x &amp;nbsp;= scan("&amp;amp;DSET" , i , '~' );&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313275#M270797</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-21T21:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313283#M270798</link>
      <description>&lt;P&gt;Tell us what your end goal is, what you need as a result of your code, i.e. is this about combining 30 tables with the same structure into a single table?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 21:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313283#M270798</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-21T21:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313306#M270799</link>
      <description>Thanks Tom. It worked very well , you have helped me minimize many un-necessary codes too .&lt;BR /&gt;&lt;BR /&gt;Thanks again</description>
      <pubDate>Mon, 21 Nov 2016 23:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-macro-variable/m-p/313306#M270799</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2016-11-21T23:49:49Z</dc:date>
    </item>
  </channel>
</rss>

