<?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 save multiple value to macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683791#M207141</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro doprint;
	%do i=1 %to &amp;amp;sqlobs;
		%put name &amp;amp;i is &amp;amp;&amp;amp;namelist&amp;amp;i;
	%end;
%mend;
%doprint&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I must ask, why do you need macro variables and macro do loops for this? Why not simply this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select name from sashelp.class
; quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which is soooooo much easier than printing via a macro do loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or why not simply this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=sashelp.class;
var name;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which is soooooo much easier than printing via a macro do loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should not resort to macros just to print data that is already in a SAS data set, this is completely unnecessary and counter-productive.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Sep 2020 22:45:21 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-09-14T22:45:21Z</dc:date>
    <item>
      <title>Proc SQL save multiple value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683788#M207138</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I copied a code from SAS book and somehow it is not working.&lt;/P&gt;
&lt;P&gt;The idea is to save all Name in a macro variable and print it one by one.&lt;/P&gt;
&lt;P&gt;Can you please help?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name into :namelist1-
from sashelp.class
; quit;

%macro doprint;
	%do i=1 %to &amp;amp;sqlobs;
		%put name &amp;amp;i is &amp;amp;namelist1&amp;amp;i;
	%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Sep 2020 22:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683788#M207138</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2020-09-14T22:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL save multiple value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683791#M207141</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro doprint;
	%do i=1 %to &amp;amp;sqlobs;
		%put name &amp;amp;i is &amp;amp;&amp;amp;namelist&amp;amp;i;
	%end;
%mend;
%doprint&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I must ask, why do you need macro variables and macro do loops for this? Why not simply this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select name from sashelp.class
; quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which is soooooo much easier than printing via a macro do loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or why not simply this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=sashelp.class;
var name;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which is soooooo much easier than printing via a macro do loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should not resort to macros just to print data that is already in a SAS data set, this is completely unnecessary and counter-productive.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 22:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683791#M207141</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-14T22:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL save multiple value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683809#M207156</link>
      <description>&lt;P&gt;Hi Paige,&lt;/P&gt;
&lt;P&gt;I am learning that Macro code from SAS book.&lt;/P&gt;
&lt;P&gt;But still, you code only give me the first row (i=1).&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2020 00:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683809#M207156</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2020-09-15T00:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL save multiple value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683813#M207157</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just tried&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;'s code, and it seems to be working for me.&amp;nbsp; Make sure you run both steps together, one right after another.&amp;nbsp; Maybe you could just cut and paste the follwing code into an editor window:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select name into :namelist1 - 
		from sashelp.class;
quit;

%macro doprint;
	%do i=1 %to &amp;amp;sqlobs;
		%put name &amp;amp;i is &amp;amp;&amp;amp;namelist&amp;amp;i;
	%end;
%mend;

%DoPrint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Make sure that "namelist" in "&amp;amp;&amp;amp;namelist&amp;amp;i" is spelled correctly.&amp;nbsp; Originally, you spelled it "namelist&lt;FONT size="4" color="#FF0000"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt;" which will not work properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2020 01:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683813#M207157</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-09-15T01:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL save multiple value to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683843#M207160</link>
      <description>&lt;P&gt;Thank you for helping.&lt;/P&gt;
&lt;P&gt;I got it!&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2020 03:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/m-p/683843#M207160</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2020-09-15T03:17:17Z</dc:date>
    </item>
  </channel>
</rss>

