<?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 macro help! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-help/m-p/47468#M9824</link>
    <description>Here is the complete code followed by the error message I am getting:&lt;BR /&gt;
&lt;BR /&gt;
%macro AgeSplit(varname=); &lt;BR /&gt;
/***Ever reported  between 9 and 13***/&lt;BR /&gt;
/***Youngest cohort (no wave E data) ***/&lt;BR /&gt;
if (agegrup=1 and f&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=1 and g&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=1 and h&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
  /***Middle cohort***/&lt;BR /&gt;
else if (agegrup=2 and d&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=2 and e&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=2 and f&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
  /***Oldest cohort***/&lt;BR /&gt;
else if (agegrup=3 and b&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=3 and c&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=3 and d&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
&lt;BR /&gt;
else &amp;amp;varname.m=0;&lt;BR /&gt;
label &amp;amp;varname.m='1+&amp;amp;lbw 14-16';&lt;BR /&gt;
%mend;&lt;BR /&gt;
%AgeSplit(varname=lbw);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Error message:&lt;BR /&gt;
1440  %AgeSplit(varname=lbw);&lt;BR /&gt;
NOTE: Line generated by the invoked macro "AGESPLIT".&lt;BR /&gt;
1      if (agegrup=1 and f&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
       --&lt;BR /&gt;
       180&lt;BR /&gt;
&lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Line generated by the invoked macro "AGESPLIT".&lt;BR /&gt;
1                                                           else if (agegrup=1 and g&amp;amp;varname ge&lt;BR /&gt;
                                                            ----&lt;BR /&gt;
                                                            180&lt;BR /&gt;
1   ! 1) then &amp;amp;varname.m=1; else if (agegrup=1 and h&amp;amp;varname ge 1) then &amp;amp;varname.m=1;    else if&lt;BR /&gt;
&lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Line generated by the invoked macro "AGESPLIT".&lt;BR /&gt;
1      else if (agegrup=1 and h&amp;amp;varname ge 1) then &amp;amp;varname.m=1;    else if (agegrup=2 and&lt;BR /&gt;
&lt;BR /&gt;
----&lt;BR /&gt;
&lt;BR /&gt;
180</description>
    <pubDate>Thu, 18 Sep 2008 03:17:21 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-09-18T03:17:21Z</dc:date>
    <item>
      <title>macro help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-help/m-p/47468#M9824</link>
      <description>Here is the complete code followed by the error message I am getting:&lt;BR /&gt;
&lt;BR /&gt;
%macro AgeSplit(varname=); &lt;BR /&gt;
/***Ever reported  between 9 and 13***/&lt;BR /&gt;
/***Youngest cohort (no wave E data) ***/&lt;BR /&gt;
if (agegrup=1 and f&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=1 and g&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=1 and h&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
  /***Middle cohort***/&lt;BR /&gt;
else if (agegrup=2 and d&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=2 and e&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=2 and f&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
  /***Oldest cohort***/&lt;BR /&gt;
else if (agegrup=3 and b&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=3 and c&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
else if (agegrup=3 and d&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
&lt;BR /&gt;
else &amp;amp;varname.m=0;&lt;BR /&gt;
label &amp;amp;varname.m='1+&amp;amp;lbw 14-16';&lt;BR /&gt;
%mend;&lt;BR /&gt;
%AgeSplit(varname=lbw);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Error message:&lt;BR /&gt;
1440  %AgeSplit(varname=lbw);&lt;BR /&gt;
NOTE: Line generated by the invoked macro "AGESPLIT".&lt;BR /&gt;
1      if (agegrup=1 and f&amp;amp;varname ge 1) then &amp;amp;varname.m=1;&lt;BR /&gt;
       --&lt;BR /&gt;
       180&lt;BR /&gt;
&lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Line generated by the invoked macro "AGESPLIT".&lt;BR /&gt;
1                                                           else if (agegrup=1 and g&amp;amp;varname ge&lt;BR /&gt;
                                                            ----&lt;BR /&gt;
                                                            180&lt;BR /&gt;
1   ! 1) then &amp;amp;varname.m=1; else if (agegrup=1 and h&amp;amp;varname ge 1) then &amp;amp;varname.m=1;    else if&lt;BR /&gt;
&lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Line generated by the invoked macro "AGESPLIT".&lt;BR /&gt;
1      else if (agegrup=1 and h&amp;amp;varname ge 1) then &amp;amp;varname.m=1;    else if (agegrup=2 and&lt;BR /&gt;
&lt;BR /&gt;
----&lt;BR /&gt;
&lt;BR /&gt;
180</description>
      <pubDate>Thu, 18 Sep 2008 03:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-help/m-p/47468#M9824</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-18T03:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: macro help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-help/m-p/47469#M9825</link>
      <description>You mix dataset statments with macro statements.&lt;BR /&gt;
Try this:&lt;BR /&gt;
&lt;BR /&gt;
data &lt;I&gt;Your_dataset_result&lt;/I&gt;;&lt;BR /&gt;
set &lt;I&gt;your_dataset_source&lt;/I&gt;;&lt;BR /&gt;
%AgeSplit(varname=lbw);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
************&lt;BR /&gt;
Also you shoul not use ' when using macro.&lt;BR /&gt;
&lt;I&gt;label &amp;amp;varname.m=&lt;B&gt;'&lt;/B&gt;1+&amp;amp;lbw 14-16&lt;B&gt;'&lt;/B&gt;;&lt;/I&gt; wont work&lt;BR /&gt;
Try this:&lt;BR /&gt;
&lt;I&gt;label &amp;amp;varname.m=&lt;B&gt;"&lt;/B&gt;1+&amp;amp;lbw 14-16&lt;B&gt;"&lt;/B&gt;;&lt;/I&gt;</description>
      <pubDate>Thu, 18 Sep 2008 10:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-help/m-p/47469#M9825</guid>
      <dc:creator>SAS_user</dc:creator>
      <dc:date>2008-09-18T10:08:35Z</dc:date>
    </item>
  </channel>
</rss>

