<?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 Trouble creating dummy variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603011#M174665</link>
    <description>&lt;P&gt;Hello! I have a data set for types of pond ice and their depths. depth is in meters and ice type is either 'multi-year', 'first-year', or 'landfast'.&lt;/P&gt;
&lt;P&gt;I need to create two dummy variables where X2=1 if icetype is 'first year', else X2=0 and X3=1 if icetype is 'multi-year', else X2=0. Landfast is irrelevant for this analysis. also X1=depth. Also, Y=broadband_alb (response)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Heres the code I tried:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ch7hw.prob76;
set problem76;&lt;BR /&gt;&lt;BR /&gt;y=broadband_alb;
X1= Depth;
if 'icetype' = 'First-Year' then X2=1; else X2=0;
if 'icetype' = 'Multi-Year' then X3=1; else X3=0;
run;
proc reg;
model y=X1 X2 X3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I keep getting errors that say "X1 not found, X2 not found X3 not found..."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I'm just formatting it incorrectly. Please help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a sample of the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;broadband_alb&lt;/CODE&gt; icetype&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0.62 Landfast&lt;BR /&gt;0.64 Landfast&lt;BR /&gt;First-Year&lt;BR /&gt;First-Year&lt;BR /&gt;0.56 First-Year&lt;BR /&gt;0.59 First-Year&lt;BR /&gt;0.67 First-Year&lt;BR /&gt;0.52 First-Year&lt;BR /&gt;0.62 First-Year&lt;BR /&gt;0.50&amp;nbsp; Multi-Year&lt;BR /&gt;0.49 Multi-Year&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to add that my data set has many other columns, but these are the only two I'm interested in at the moment.&lt;/P&gt;</description>
    <pubDate>Sat, 09 Nov 2019 20:40:58 GMT</pubDate>
    <dc:creator>valarievil</dc:creator>
    <dc:date>2019-11-09T20:40:58Z</dc:date>
    <item>
      <title>Trouble creating dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603011#M174665</link>
      <description>&lt;P&gt;Hello! I have a data set for types of pond ice and their depths. depth is in meters and ice type is either 'multi-year', 'first-year', or 'landfast'.&lt;/P&gt;
&lt;P&gt;I need to create two dummy variables where X2=1 if icetype is 'first year', else X2=0 and X3=1 if icetype is 'multi-year', else X2=0. Landfast is irrelevant for this analysis. also X1=depth. Also, Y=broadband_alb (response)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Heres the code I tried:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ch7hw.prob76;
set problem76;&lt;BR /&gt;&lt;BR /&gt;y=broadband_alb;
X1= Depth;
if 'icetype' = 'First-Year' then X2=1; else X2=0;
if 'icetype' = 'Multi-Year' then X3=1; else X3=0;
run;
proc reg;
model y=X1 X2 X3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I keep getting errors that say "X1 not found, X2 not found X3 not found..."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I'm just formatting it incorrectly. Please help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a sample of the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;broadband_alb&lt;/CODE&gt; icetype&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0.62 Landfast&lt;BR /&gt;0.64 Landfast&lt;BR /&gt;First-Year&lt;BR /&gt;First-Year&lt;BR /&gt;0.56 First-Year&lt;BR /&gt;0.59 First-Year&lt;BR /&gt;0.67 First-Year&lt;BR /&gt;0.52 First-Year&lt;BR /&gt;0.62 First-Year&lt;BR /&gt;0.50&amp;nbsp; Multi-Year&lt;BR /&gt;0.49 Multi-Year&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to add that my data set has many other columns, but these are the only two I'm interested in at the moment.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Nov 2019 20:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603011#M174665</guid>
      <dc:creator>valarievil</dc:creator>
      <dc:date>2019-11-09T20:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble creating dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603012#M174666</link>
      <description>&lt;P&gt;is icetype a variable&amp;nbsp; or constant. Assuming it's a variable, you wouldn't enclose a variable name in quotes. So please remove the quotes. Quotes are only for &lt;STRONG&gt;char values.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ch7hw.prob76;
set problem76;y=broadband_alb;
X1= Depth;
if icetype = 'First-Year' then X2=1; else X2=0;
else if icetype = 'Multi-Year' then X3=1; else X3=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Nov 2019 20:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603012#M174666</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-09T20:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble creating dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603014#M174668</link>
      <description>&lt;P&gt;There are many ways to create dummy variables that are built into SAS, so &lt;STRONG&gt;YOU DON'T HAVE TO DO IT YOURSELF&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many PROCs that do statistical analysis have a CLASS statement, which will create the dummy variables for you. If you do this regression in PROC GLM, the CLASS statement creates the dummy variables for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If for some reason (which most beginners don't have), you need a data set to contain the dummy variables, there is PROC GLMMOD and also several other methods, as explained in this long thread &lt;A href="https://communities.sas.com/t5/SAS-Procedures/How-can-i-create-dummy-variables-How-can-i-change-my-code/m-p/404308#M66929" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Procedures/How-can-i-create-dummy-variables-How-can-i-change-my-code/m-p/404308#M66929&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Nov 2019 21:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603014#M174668</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-09T21:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble creating dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603016#M174669</link>
      <description>&lt;P&gt;Unless your homework requires that you use &lt;STRONG&gt;proc reg&lt;/STRONG&gt;, you would get better results with less effort with&lt;STRONG&gt; proc glm&lt;/STRONG&gt;. Just drop the data step and do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm data=ch7hw.prob76;
class icetype;
model broadband_alb = depth iceType  / solution;
lsmeans iceType / at depth = &amp;lt;some value&amp;gt; pdiff;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The lsmeans statement provides comparisons of mean broadband_alb for different iceType values at a given depth. If you suspect that depth effect might not be the same for different iceType values, add the term &lt;EM&gt;iceType*depth&lt;/EM&gt; to the model.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Nov 2019 21:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603016#M174669</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-11-09T21:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble creating dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603018#M174671</link>
      <description>&lt;P&gt;I'm still getting the error "Variable X1, X2, X3 not found" &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Nov 2019 22:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603018#M174671</guid>
      <dc:creator>valarievil</dc:creator>
      <dc:date>2019-11-09T22:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble creating dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603022#M174675</link>
      <description>&lt;P&gt;Please post a sample of your input data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your current sample, I can't see the variable DEPTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA have;
input broadband_alb icetype $20.;
cards;
0.62 Landfast
0.64 Landfast
. First-Year
. First-Year
0.56 First-Year
0.59 First-Year
0.67 First-Year
0.52 First-Year
0.62 First-Year
0.50  Multi-Year
0.49 Multi-Year
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Nov 2019 22:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603022#M174675</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-09T22:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble creating dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603069#M174702</link>
      <description>&lt;P&gt;your right I forgot to add the depth column&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 20:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603069#M174702</guid>
      <dc:creator>valarievil</dc:creator>
      <dc:date>2019-11-10T20:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble creating dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603098#M174713</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294895"&gt;@valarievil&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm still getting the error "Variable X1, X2, X3 not found" &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We need to see the ENTIRE log from this program, not just the error messages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please copy the log as text (not a screen capture) and then paste it here at the SAS Communities into the window that appears when you click on the &lt;FONT face="courier new,courier"&gt;{i}&lt;/FONT&gt; icon. &lt;STRONG&gt;Do not skip this step&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 23:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-creating-dummy-variables/m-p/603098#M174713</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-10T23:19:16Z</dc:date>
    </item>
  </channel>
</rss>

