<?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: How SAS calculates regression with dummy variables? in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-SAS-calculates-regression-with-dummy-variables/m-p/367784#M2429</link>
    <description>&lt;P&gt;Look up "dummy variable trap." With dummy variables, you need the number of levels - 1 in the model. The one left out is the base against which the other paremeters are based. &amp;nbsp;At the most basic level, with two levels you need one dummy and the coefficient is the the effect of being one compared to whatever is zero.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Jun 2017 16:12:57 GMT</pubDate>
    <dc:creator>collinelliot</dc:creator>
    <dc:date>2017-06-16T16:12:57Z</dc:date>
    <item>
      <title>How SAS calculates regression with dummy variables?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-SAS-calculates-regression-with-dummy-variables/m-p/367777#M2428</link>
      <description>&lt;P&gt;Hello, everybody.&lt;BR /&gt;I want to regress dummy variables, which are time-based, on volume and use PROC GENMOD and PROC GLM statements to create dummies automatically.&lt;BR /&gt;In addition, I use DATA statement to create dummies manually. I have seven dummies which are classified as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dummy_1: 9:00 &amp;lt;&amp;lt; Time &amp;lt; 9:30;&lt;/P&gt;&lt;P&gt;Dummy_2: 9:30 &amp;lt;&amp;lt; &lt;SPAN&gt;Time&amp;nbsp;&lt;/SPAN&gt;&amp;lt; 10:00;&lt;/P&gt;&lt;P&gt;Dummy_3: 10:00 &amp;lt;&amp;lt; &lt;SPAN&gt;Time&lt;/SPAN&gt;&amp;nbsp;&amp;lt; 10:30;&lt;/P&gt;&lt;P&gt;Dummy_4: 10:30 &amp;lt;&amp;lt; &lt;SPAN&gt;Time&lt;/SPAN&gt;&amp;nbsp;&amp;lt; 11;&lt;/P&gt;&lt;P&gt;Dummy_5: 11:00 &amp;lt;&amp;lt; &lt;SPAN&gt;Time&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt; 11:30;&lt;/P&gt;&lt;P&gt;Dummy_6: 11:30 &amp;lt;&amp;lt; &lt;SPAN&gt;Time&lt;/SPAN&gt;&amp;nbsp;&amp;lt; 12;&lt;/P&gt;&lt;P&gt;Dummy_7: 12 &amp;lt;&amp;lt; &lt;SPAN&gt;Time&lt;/SPAN&gt;&amp;nbsp;&amp;lt; 12:30;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here&amp;nbsp;are some examples of my codes:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Regressing dummy variables on normalized volume variable using calculated volume;
proc genmod data=Sampledata_adjvol;
   class TRD_EVENT_ROUFOR / param=effect;
   model adjusted_volume = TRD_EVENT_ROUFOR / noscale;
   ods select ParameterEstimates;
run;

* Same analysis by using the CLASS statement;
proc glm data=Sampledata_adjvol;
   class TRD_EVENT_ROUFOR;              /* Generates dummy variables internally */
   model adjusted_volume = TRD_EVENT_ROUFOR / solution;
   ods select ParameterEstimates;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Creating dummy variables manually;
data Sampledata_adjvol_DumVar;
  set Sampledata_adjvol ;
  	if TRD_EVENT_ROUNDED = 34200 then TRD_EVENT_ROUNDED_1 = 1; 
    else TRD_EVENT_ROUNDED_1 = 0;
  	if TRD_EVENT_ROUNDED = 36000 then TRD_EVENT_ROUNDED_2 = 1; 
    else TRD_EVENT_ROUNDED_2 = 0;
  	if TRD_EVENT_ROUNDED = 37800 then TRD_EVENT_ROUNDED_3 = 1; 
    else TRD_EVENT_ROUNDED_3 = 0;
 	if TRD_EVENT_ROUNDED = 39600 then TRD_EVENT_ROUNDED_4 = 1; 
    else TRD_EVENT_ROUNDED_4 = 0;
	if TRD_EVENT_ROUNDED = 41400 then TRD_EVENT_ROUNDED_5 = 1; 
    else TRD_EVENT_ROUNDED_5 = 0;
	if TRD_EVENT_ROUNDED = 43200 then TRD_EVENT_ROUNDED_6 = 1; 
    else TRD_EVENT_ROUNDED_6 = 0;
	if TRD_EVENT_ROUNDED = 45000 then TRD_EVENT_ROUNDED_7 = 1; 
    else TRD_EVENT_ROUNDED_7 = 0;
run;
proc freq data=Sampledata_adjvol_DumVar;
  tables TRD_EVENT_ROUNDED*TRD_EVENT_ROUNDED_1*TRD_EVENT_ROUNDED_2*TRD_EVENT_ROUNDED_3*TRD_EVENT_ROUNDED_4*TRD_EVENT_ROUNDED_5*TRD_EVENT_ROUNDED_6*TRD_EVENT_ROUNDED_7 / list ;
run;

* Regressing dummy variables on normalized volume variable using calculated volume;
 ods graphics on;
proc reg data = Sampledata_adjvol_DumVar plots(maxpoints = none);
	model adjusted_volume = TRD_EVENT_ROUNDED_1 TRD_EVENT_ROUNDED_2 TRD_EVENT_ROUNDED_3 TRD_EVENT_ROUNDED_4 TRD_EVENT_ROUNDED_5 TRD_EVENT_ROUNDED_6 TRD_EVENT_ROUNDED_7;
run;
 ods graphics off;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The results are attached to this post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why the final dummy is not estimated?&lt;/P&gt;&lt;P&gt;What is the problem?&lt;/P&gt;&lt;P&gt;How can I fix that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 17:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-SAS-calculates-regression-with-dummy-variables/m-p/367777#M2428</guid>
      <dc:creator>aminkarimid</dc:creator>
      <dc:date>2017-06-16T17:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: How SAS calculates regression with dummy variables?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-SAS-calculates-regression-with-dummy-variables/m-p/367784#M2429</link>
      <description>&lt;P&gt;Look up "dummy variable trap." With dummy variables, you need the number of levels - 1 in the model. The one left out is the base against which the other paremeters are based. &amp;nbsp;At the most basic level, with two levels you need one dummy and the coefficient is the the effect of being one compared to whatever is zero.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 16:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-SAS-calculates-regression-with-dummy-variables/m-p/367784#M2429</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-06-16T16:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: How SAS calculates regression with dummy variables?</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-SAS-calculates-regression-with-dummy-variables/m-p/367808#M2430</link>
      <description>&lt;P&gt;As explained above, if you have N levels, you can only estimate n-1 coefficients plus the intercept. If you leave the intercept out of the model, then you can estimate all N levels. This is basic math.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you keep writing something like this, in this and other threads&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;First half an hour: 9:00 &amp;lt;&amp;lt; Dummy_1 &amp;lt; 9:30;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which makes absolutely no sense at all, dummy_1 is either 0 or 1 (otherwise it's not a dummy variable), and a variable that has values of 0 or 1 cannot be between 9:00 and 9:30. You most likely mean&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dummy1 = 9:00 &amp;lt;= time_1 &amp;lt; 9:30;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;(which might not be correct syntax, but you get the idea)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so I would hope that you will write more meaningful and understandable math and SAS code in the future.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 17:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/How-SAS-calculates-regression-with-dummy-variables/m-p/367808#M2430</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-06-16T17:21:49Z</dc:date>
    </item>
  </channel>
</rss>

