<?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: residuals in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624860#M184117</link>
    <description>&lt;P&gt;Thanks ed_sas_member.&lt;/P&gt;
&lt;P&gt;I have a lot of variables so the second option would involve writing a lot of code.&lt;/P&gt;
&lt;P&gt;With your first option, is it intended that I insert my variable names in the first var only?&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token macrobound"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;%macro&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;reg&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;&lt;FONT color="#0000ff"&gt;var1, var2, var3....&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color="#999999"&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;proc&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;reg&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt;work&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;.&lt;/FONT&gt;&lt;/SPAN&gt;My_data&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;model&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;&amp;amp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;&lt;FONT color="#0000ff"&gt;var&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt;E&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;output out&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt;cal3_resid_&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;&amp;amp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;&lt;FONT color="#0000ff"&gt;var&lt;/FONT&gt;&lt;/SPAN&gt; r&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt;residual&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token macrobound"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;%mend&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;Thanks.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Feb 2020 15:25:21 GMT</pubDate>
    <dc:creator>catch18</dc:creator>
    <dc:date>2020-02-14T15:25:21Z</dc:date>
    <item>
      <title>residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624765#M184081</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I regressed several&amp;nbsp;response variables defined as &amp;amp;xlist on an independent variable with the code below:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;reg&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=work.'My_data';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;model &lt;/FONT&gt;&amp;amp;xlist&lt;FONT face="Courier New" size="2"&gt;=E;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;output&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; = cal3_resid &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;r&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; =residual;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;amp;xlist= Var1 var2 var3....;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;How do I get r=residual to have a separate name for each variable defined by &amp;amp;xlist? &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 09:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624765#M184081</guid>
      <dc:creator>catch18</dc:creator>
      <dc:date>2020-02-14T09:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624771#M184084</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293117"&gt;@catch18&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure that such an option exists. Depending on the number of dependents variables you have, I suggest that you use a macro like this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro reg (var);
	proc reg data=work.My_data;
		model &amp;amp;var.=E;
		output out=cal3_resid_&amp;amp;var r=residual;
	run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc reg data=work.My_data;
	model var1=E;
	output out=cal3_resid_var1 r=residual;
	model var2=E;
	output out=cal3_resid_var2 r=residual;
...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 10:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624771#M184084</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-14T10:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624789#M184090</link>
      <description>&lt;P&gt;You could create another macro variable that has the list of residual names. You could do this in a number of ways, appending _R to the end of the variable names, thus creating a list for the residual variables.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 12:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624789#M184090</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-14T12:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624860#M184117</link>
      <description>&lt;P&gt;Thanks ed_sas_member.&lt;/P&gt;
&lt;P&gt;I have a lot of variables so the second option would involve writing a lot of code.&lt;/P&gt;
&lt;P&gt;With your first option, is it intended that I insert my variable names in the first var only?&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token macrobound"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;%macro&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;reg&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;&lt;FONT color="#0000ff"&gt;var1, var2, var3....&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color="#999999"&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;proc&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;reg&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt;work&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;.&lt;/FONT&gt;&lt;/SPAN&gt;My_data&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;model&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;&amp;amp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;&lt;FONT color="#0000ff"&gt;var&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt;E&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;output out&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt;cal3_resid_&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;&amp;amp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;&lt;FONT color="#0000ff"&gt;var&lt;/FONT&gt;&lt;/SPAN&gt; r&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt;residual&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token macrobound"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;%mend&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;Thanks.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 15:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624860#M184117</guid>
      <dc:creator>catch18</dc:creator>
      <dc:date>2020-02-14T15:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624864#M184119</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293117"&gt;@catch18&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're welcome.&lt;/P&gt;
&lt;P&gt;With the first option, you can execute it as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=work.My_data out=work.listvar (keep=name) noprint;
run;
/* Add a data step to keep only those variables you are interested in*/
data _null;
	set listvar;
	rc= dosubl(cats('%reg(',name,')'));
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is exactly the same as writing multiple macro call :&lt;/P&gt;
&lt;P&gt;%reg(var1)&lt;/P&gt;
&lt;P&gt;%reg(var2)&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;%reg(varn)&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 15:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624864#M184119</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-14T15:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624866#M184120</link>
      <description>&lt;P&gt;It would seem to me that some sort of looping is unavoidable in this case.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dothis;
%let xlist= Var1 var2 var3;
%let residlist=;
%do i=1 %to %sysfunc(countw(&amp;amp;xlist));
    %let residlist=&amp;amp;residlist %scan(&amp;amp;xlist,&amp;amp;i,%str( ))_r;
%end;
proc reg data=have;
model &amp;amp;xlist=E;
output out = want r =&amp;amp;residlist;
run;
%mend;
%dothis &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Feb 2020 15:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624866#M184120</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-14T15:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624869#M184122</link>
      <description>&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 15:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624869#M184122</guid>
      <dc:creator>catch18</dc:creator>
      <dc:date>2020-02-14T15:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624870#M184123</link>
      <description>&lt;P&gt;The drawback to calling PROC REG in a loop&amp;nbsp;many times (or calling PROC REG many times via CALL EXECUTE or DOSUBL) is that PROC REG then has to pass through the data many times and invert the X'X matrix many times. If you only call PROC REG one time (as in my solution) then you only have to pass through the data once and you only have to invert the X'X matrix once.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 18:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624870#M184123</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-14T18:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624923#M184151</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 18:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/residuals/m-p/624923#M184151</guid>
      <dc:creator>catch18</dc:creator>
      <dc:date>2020-02-14T18:31:32Z</dc:date>
    </item>
  </channel>
</rss>

