<?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: Why proc print made error? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-proc-print-made-error/m-p/890133#M351721</link>
    <description>Calling %cols2 generates all the text within the macro:&lt;BR /&gt;&lt;BR /&gt;height weight;&lt;BR /&gt;&lt;BR /&gt;Extrapolating upon this, your full VAR statement generates:&lt;BR /&gt;&lt;BR /&gt;var height weight; name age;&lt;BR /&gt;&lt;BR /&gt;Clearly, there's an extra semicolon.   A good solution would be to remove the generated semicolons from the macro definition.   Have %cols2 generate only:&lt;BR /&gt;&lt;BR /&gt;height weight&lt;BR /&gt;&lt;BR /&gt;Then add a semicolon for the VAR statement when calling the macros:&lt;BR /&gt;&lt;BR /&gt;var %cols2 %cols1 ;</description>
    <pubDate>Sun, 20 Aug 2023 23:52:10 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2023-08-20T23:52:10Z</dc:date>
    <item>
      <title>Why proc print made error?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-proc-print-made-error/m-p/890131#M351720</link>
      <description>&lt;P&gt;data a;&lt;BR /&gt;input name $ age height weight;&lt;BR /&gt;datalines;&lt;BR /&gt;don 28 168 76&lt;BR /&gt;;run;&lt;BR /&gt;%macro cols1; name age; %mend;&lt;BR /&gt;%macro cols2; height weight; %mend;&lt;BR /&gt;proc print data = a; var %cols2 %cols1; run;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2023 23:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-proc-print-made-error/m-p/890131#M351720</guid>
      <dc:creator>randomman</dc:creator>
      <dc:date>2023-08-20T23:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why proc print made error?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-proc-print-made-error/m-p/890133#M351721</link>
      <description>Calling %cols2 generates all the text within the macro:&lt;BR /&gt;&lt;BR /&gt;height weight;&lt;BR /&gt;&lt;BR /&gt;Extrapolating upon this, your full VAR statement generates:&lt;BR /&gt;&lt;BR /&gt;var height weight; name age;&lt;BR /&gt;&lt;BR /&gt;Clearly, there's an extra semicolon.   A good solution would be to remove the generated semicolons from the macro definition.   Have %cols2 generate only:&lt;BR /&gt;&lt;BR /&gt;height weight&lt;BR /&gt;&lt;BR /&gt;Then add a semicolon for the VAR statement when calling the macros:&lt;BR /&gt;&lt;BR /&gt;var %cols2 %cols1 ;</description>
      <pubDate>Sun, 20 Aug 2023 23:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-proc-print-made-error/m-p/890133#M351721</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-08-20T23:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Why proc print made error?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-proc-print-made-error/m-p/890137#M351722</link>
      <description>&lt;P&gt;Remove the semicolons and your code will work.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1692585470737.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86855iD269E87470297F86/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1692585470737.png" alt="Patrick_0-1692585470737.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You normally only use macros for dynamic code generation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your case you'd rather use macro variables as in below sample code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cols1=name age;
%let cols2=height weight;

proc print data = a;
  var &amp;amp;cols2 &amp;amp;cols1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;A macro definition for your sample could look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro doit(cols1,cols2);
  proc print data = a;
    var &amp;amp;cols2 &amp;amp;cols1;
  run;
%mend;

%doit(name age, height weight);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And as an advice: Don't dive too early into SAS macro coding. First get "solid" with SAS data step and SAS Proc's.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 02:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-proc-print-made-error/m-p/890137#M351722</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-08-21T02:44:45Z</dc:date>
    </item>
  </channel>
</rss>

