<?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 How to create dummy variables for an interval categorical variable to use in proc reg in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables-for-an-interval-categorical/m-p/518270#M140246</link>
    <description>&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to structure my data to run a regression including a categorical variable with multiple interval levels. The variable is viral load control, which was created by looking at lab results across a longitudinal period (VLCONTROL), which has a range of possible values from 1 - 4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variable is formatted as a mutually exclusive set of ranges for each response category as defined below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all were &amp;lt;50 then vlcontrol=1&lt;/P&gt;&lt;P&gt;If any &amp;gt;=50 and all &amp;lt;400 then vlcontrol=2&lt;/P&gt;&lt;P&gt;If any &amp;gt;=400 and &amp;lt;1000 then vlcontrol=3&lt;/P&gt;&lt;P&gt;If any &amp;gt;=1000 then vlcontrol=4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attempted to create a series of dummy variables to run a linear regression in proc reg, but I got the following error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV align="left"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Note:&lt;/TD&gt;&lt;TD&gt;Model is not full rank. Least-squares solutions for the parameters are not unique. Some statistics will be misleading. A reported DF of 0 or B means that the estimate is biased.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV align="left"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Note:&lt;/TD&gt;&lt;TD&gt;The following parameters have been set to 0, since the variables are a linear combination of other variables as shown.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is how I coded the dummy variables and how I ran the model:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data regression;
	keep ctvalue vlcontrol vlcont_50 vlcont_400 vlcont_1000 vlcont_ge1000; 
	set have;
	vlcont_50=0;
		if vlcontrol=1 then vlcont_50=1;
	vlcont_400=0;
		if vlcontrol=2 then vlcont_400=1;
	vlcont_1000=0;
		if vlcontrol=3 then vl_1000=1;
	vlcont_ge1000=0;
		if vlcontrol=4 then vlcont_ge1000=1;
	run;

proc reg data=regression outest=est;
	model ctvalue=vlcont_50 vlcont_400 vlcont_1000 vlcont_ge1000/  clb rsquare tol vif aic bic;
	id pid;
	ods output ParameterEstimates=PE;
	run;quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure how to do this better. I know I can do this in PROC GLM etc, but I want the diagnostic features for building a model in PROC REG. I've tried not including the last dummy variable, vlcontrol_ge1000, in the model, but still get the same error note in the output. Is there a better way I should be coding my dummy variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Cara&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Dec 2018 23:11:38 GMT</pubDate>
    <dc:creator>cbt2119</dc:creator>
    <dc:date>2018-12-03T23:11:38Z</dc:date>
    <item>
      <title>How to create dummy variables for an interval categorical variable to use in proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables-for-an-interval-categorical/m-p/518270#M140246</link>
      <description>&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to structure my data to run a regression including a categorical variable with multiple interval levels. The variable is viral load control, which was created by looking at lab results across a longitudinal period (VLCONTROL), which has a range of possible values from 1 - 4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variable is formatted as a mutually exclusive set of ranges for each response category as defined below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all were &amp;lt;50 then vlcontrol=1&lt;/P&gt;&lt;P&gt;If any &amp;gt;=50 and all &amp;lt;400 then vlcontrol=2&lt;/P&gt;&lt;P&gt;If any &amp;gt;=400 and &amp;lt;1000 then vlcontrol=3&lt;/P&gt;&lt;P&gt;If any &amp;gt;=1000 then vlcontrol=4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attempted to create a series of dummy variables to run a linear regression in proc reg, but I got the following error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV align="left"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Note:&lt;/TD&gt;&lt;TD&gt;Model is not full rank. Least-squares solutions for the parameters are not unique. Some statistics will be misleading. A reported DF of 0 or B means that the estimate is biased.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV align="left"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Note:&lt;/TD&gt;&lt;TD&gt;The following parameters have been set to 0, since the variables are a linear combination of other variables as shown.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is how I coded the dummy variables and how I ran the model:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data regression;
	keep ctvalue vlcontrol vlcont_50 vlcont_400 vlcont_1000 vlcont_ge1000; 
	set have;
	vlcont_50=0;
		if vlcontrol=1 then vlcont_50=1;
	vlcont_400=0;
		if vlcontrol=2 then vlcont_400=1;
	vlcont_1000=0;
		if vlcontrol=3 then vl_1000=1;
	vlcont_ge1000=0;
		if vlcontrol=4 then vlcont_ge1000=1;
	run;

proc reg data=regression outest=est;
	model ctvalue=vlcont_50 vlcont_400 vlcont_1000 vlcont_ge1000/  clb rsquare tol vif aic bic;
	id pid;
	ods output ParameterEstimates=PE;
	run;quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure how to do this better. I know I can do this in PROC GLM etc, but I want the diagnostic features for building a model in PROC REG. I've tried not including the last dummy variable, vlcontrol_ge1000, in the model, but still get the same error note in the output. Is there a better way I should be coding my dummy variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Cara&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 23:11:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables-for-an-interval-categorical/m-p/518270#M140246</guid>
      <dc:creator>cbt2119</dc:creator>
      <dc:date>2018-12-03T23:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables for an interval categorical variable to use in proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables-for-an-interval-categorical/m-p/518271#M140247</link>
      <description>Generally, when you have 4 levels, you only need 3 dummy variables to accurately represent it, not 4. So you can remove one of your dummy variables, which becomes your reference level and the remaining will be fine.&lt;BR /&gt;</description>
      <pubDate>Mon, 03 Dec 2018 23:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables-for-an-interval-categorical/m-p/518271#M140247</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-03T23:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables for an interval categorical variable to use in proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables-for-an-interval-categorical/m-p/518282#M140254</link>
      <description>Thanks, this worked! I had to create the dummy variable for the last level and just leave it out of the model for it to work.</description>
      <pubDate>Tue, 04 Dec 2018 00:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables-for-an-interval-categorical/m-p/518282#M140254</guid>
      <dc:creator>cbt2119</dc:creator>
      <dc:date>2018-12-04T00:34:31Z</dc:date>
    </item>
  </channel>
</rss>

