<?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 an error message in proc sql within a mcaro: not sure why in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/an-error-message-in-proc-sql-within-a-mcaro-not-sure-why/m-p/243270#M55918</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro both(ds1,ds2,ds3);
	proc sql;
		create &amp;amp;ds3. as 
			select one.ID, one.Gender, one.ZIP, one.State, one.age 
				from &amp;amp;ds1. as one, &amp;amp;ds2. as two
					where one.ID=two.ID;
%mend;
%put %both(data1,data2,test)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to select the observations with same ID from two files, and because I need to do this repeatedly (I have 7 data sets), so I wrote the above macro. Howeverm when I called it using the %put statement, I got an error:&lt;/P&gt;
&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order (create was underlined to indicate the error position).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do I get this error? Can anyone kindly give me some hint if you know about it? Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jan 2016 17:43:30 GMT</pubDate>
    <dc:creator>fengyuwuzu</dc:creator>
    <dc:date>2016-01-13T17:43:30Z</dc:date>
    <item>
      <title>an error message in proc sql within a mcaro: not sure why</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-error-message-in-proc-sql-within-a-mcaro-not-sure-why/m-p/243270#M55918</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro both(ds1,ds2,ds3);
	proc sql;
		create &amp;amp;ds3. as 
			select one.ID, one.Gender, one.ZIP, one.State, one.age 
				from &amp;amp;ds1. as one, &amp;amp;ds2. as two
					where one.ID=two.ID;
%mend;
%put %both(data1,data2,test)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to select the observations with same ID from two files, and because I need to do this repeatedly (I have 7 data sets), so I wrote the above macro. Howeverm when I called it using the %put statement, I got an error:&lt;/P&gt;
&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order (create was underlined to indicate the error position).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do I get this error? Can anyone kindly give me some hint if you know about it? Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 17:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-error-message-in-proc-sql-within-a-mcaro-not-sure-why/m-p/243270#M55918</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-01-13T17:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: an error message in proc sql within a mcaro: not sure why</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-error-message-in-proc-sql-within-a-mcaro-not-sure-why/m-p/243316#M55921</link>
      <description>&lt;P&gt;Almost always, it will be wrong to call a macro inside a %PUT statement.&amp;nbsp; In this case, it is definitely wrong.&amp;nbsp; Here is the beginning of your result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put proc sql;&lt;/P&gt;
&lt;P&gt;create table ds3 as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp; you coded this yourself, you would expect to get an error.&amp;nbsp; The %PUT statement would write "proc sql" and then SAS would try to execute "create table ds3 as ...".&amp;nbsp; Since there is no longer a PROC SQL statement as part of the SAS program, "create table ds3 as ..." gives&amp;nbsp; you the error message.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 20:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-error-message-in-proc-sql-within-a-mcaro-not-sure-why/m-p/243316#M55921</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-13T20:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: an error message in proc sql within a mcaro: not sure why</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/an-error-message-in-proc-sql-within-a-mcaro-not-sure-why/m-p/243330#M55924</link>
      <description>&lt;P&gt;I would try something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro both(ds1,ds2,ds3);
	proc sql;
		create &amp;amp;ds3. as 
			select one.ID, one.Gender, one.ZIP, one.State, one.age 
				from &amp;amp;ds1. as one, &amp;amp;ds2. as two
					where one.ID=two.ID;
        quit;
%mend;

%both(data1,data2,test);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to see what the generated code looks like then use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options mprint;&lt;/P&gt;
&lt;P&gt;before running the macro.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 20:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/an-error-message-in-proc-sql-within-a-mcaro-not-sure-why/m-p/243330#M55924</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-13T20:56:37Z</dc:date>
    </item>
  </channel>
</rss>

