<?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 linear regression macro - proc glm class statement - unused variables in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309523#M16369</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a model I would like to run with with a series of independent and dependent variables. I have written a macro to do this. Some of the independent&amp;nbsp;variables are categorical, thus, I included these variables in the class statement. However, I realized that putting&amp;nbsp;unused variables in class statement limits sample&amp;nbsp;for each analysis because the observations used in the regression are limited to those with values for all class statement variables. How can i fix this? Also, any suggestions to make code more efficient would be helpful. My list after %mend is VERY long. Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code sample:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%macro model(dep, indep);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc glm data=data1 ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;class var2 (ref=first) indep1&amp;nbsp;(ref=first) indep2&amp;nbsp;(ref=first)indep3&amp;nbsp;(ref=first)&amp;nbsp;indep4&amp;nbsp;(ref=first) indep5&amp;nbsp;(ref=first);&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;model &amp;amp;dep= &amp;amp;indep&amp;nbsp;var2&amp;nbsp;var3&amp;nbsp;var4/solution;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%mend;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep1);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep2);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep3);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep4);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep5);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep2, indep1);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep2, indep2);&lt;/FONT&gt;&lt;BR /&gt;.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Nov 2016 18:45:50 GMT</pubDate>
    <dc:creator>pamplemouse22</dc:creator>
    <dc:date>2016-11-05T18:45:50Z</dc:date>
    <item>
      <title>linear regression macro - proc glm class statement - unused variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309523#M16369</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a model I would like to run with with a series of independent and dependent variables. I have written a macro to do this. Some of the independent&amp;nbsp;variables are categorical, thus, I included these variables in the class statement. However, I realized that putting&amp;nbsp;unused variables in class statement limits sample&amp;nbsp;for each analysis because the observations used in the regression are limited to those with values for all class statement variables. How can i fix this? Also, any suggestions to make code more efficient would be helpful. My list after %mend is VERY long. Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code sample:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%macro model(dep, indep);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc glm data=data1 ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;class var2 (ref=first) indep1&amp;nbsp;(ref=first) indep2&amp;nbsp;(ref=first)indep3&amp;nbsp;(ref=first)&amp;nbsp;indep4&amp;nbsp;(ref=first) indep5&amp;nbsp;(ref=first);&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;model &amp;amp;dep= &amp;amp;indep&amp;nbsp;var2&amp;nbsp;var3&amp;nbsp;var4/solution;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%mend;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep1);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep2);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep3);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep4);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep1, indep5);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep2, indep1);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%model(dep2, indep2);&lt;/FONT&gt;&lt;BR /&gt;.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 18:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309523#M16369</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2016-11-05T18:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: linear regression macro - proc glm class statement - unused variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309528#M16371</link>
      <description>&lt;P&gt;How about :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro model(dep, indepc, indep);

proc glm data = data1 ;
class var2 &amp;amp;indepc / ref = first;
model &amp;amp;dep = &amp;amp;indep &amp;amp;indepc var2 var3 var4 / solution;
run;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you would specify one of indepc or indep in your macro call, depending if your variable is categorical or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%model(dep1, indep4, );&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%model(dep2, , indep99);&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 20:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309528#M16371</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-11-05T20:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: linear regression macro - proc glm class statement - unused variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309532#M16373</link>
      <description>&lt;P&gt;The CLASS statement doesn't require a variable, it can be empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie the following won't affect your output, where the macro variable is blank.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let indepn=;&lt;BR /&gt;&lt;BR /&gt;proc glm data=...;&lt;BR /&gt;&lt;BR /&gt;CLASS &amp;amp;indepn;&lt;BR /&gt;...&lt;BR /&gt;run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Nov 2016 21:31:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309532#M16373</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-05T21:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: linear regression macro - proc glm class statement - unused variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309912#M16397</link>
      <description>&lt;P&gt;Oh, good idea. This works! Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2016 00:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309912#M16397</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2016-11-08T00:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: linear regression macro - proc glm class statement - unused variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309913#M16398</link>
      <description>&lt;P&gt;Oh I see. Didn't think of calling up the macro variable in the Class statement. Will try. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2016 00:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/linear-regression-macro-proc-glm-class-statement-unused/m-p/309913#M16398</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2016-11-08T00:07:42Z</dc:date>
    </item>
  </channel>
</rss>

