<?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 Creating two dummy variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-two-dummy-variables/m-p/779638#M248347</link>
    <description>&lt;P&gt;I'm creating dummy variables for the first time!&lt;/P&gt;&lt;P&gt;I am using data from NHANES.&lt;/P&gt;&lt;P&gt;I have a variable &lt;STRONG&gt;smoke_hx&lt;/STRONG&gt; where 0= never smoked, 1=past smoker, 2=current smoker.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create the variables&lt;STRONG&gt; ever_smoked1&lt;/STRONG&gt; that is a dummy for smoke_hx=1 and &lt;STRONG&gt;ever_smoked2&lt;/STRONG&gt; which is a dummy for smoke_hx=2. Never smoked is the reference group.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I create these dummy variables? I've read a bunch of explanations but nothing is making sense!&lt;/P&gt;</description>
    <pubDate>Wed, 10 Nov 2021 20:00:46 GMT</pubDate>
    <dc:creator>westbestern</dc:creator>
    <dc:date>2021-11-10T20:00:46Z</dc:date>
    <item>
      <title>Creating two dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-two-dummy-variables/m-p/779638#M248347</link>
      <description>&lt;P&gt;I'm creating dummy variables for the first time!&lt;/P&gt;&lt;P&gt;I am using data from NHANES.&lt;/P&gt;&lt;P&gt;I have a variable &lt;STRONG&gt;smoke_hx&lt;/STRONG&gt; where 0= never smoked, 1=past smoker, 2=current smoker.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create the variables&lt;STRONG&gt; ever_smoked1&lt;/STRONG&gt; that is a dummy for smoke_hx=1 and &lt;STRONG&gt;ever_smoked2&lt;/STRONG&gt; which is a dummy for smoke_hx=2. Never smoked is the reference group.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I create these dummy variables? I've read a bunch of explanations but nothing is making sense!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 20:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-two-dummy-variables/m-p/779638#M248347</guid>
      <dc:creator>westbestern</dc:creator>
      <dc:date>2021-11-10T20:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating two dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-two-dummy-variables/m-p/779641#M248348</link>
      <description>Why?&lt;BR /&gt;If the CLASS statement exists with in the procedure it will do the dummy coding for you, no need to do that manually.</description>
      <pubDate>Wed, 10 Nov 2021 20:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-two-dummy-variables/m-p/779641#M248348</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T20:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating two dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-two-dummy-variables/m-p/779645#M248351</link>
      <description>&lt;P&gt;Good to know! But for this class, my professor is requiring us to manually create them. This is the code I have. Not sure if it's correct.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Why?&lt;BR /&gt;If the CLASS statement exists with in the procedure it will do the dummy coding for you, no need to do that manually.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data data2;
set data1;
	if smoke_hx=1 then ever_smoked1=1;
	else ever_smoked1=0;
	if smoke_hx=2 then ever_smoked2=1;
	else ever_smoked2=0;
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 20:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-two-dummy-variables/m-p/779645#M248351</guid>
      <dc:creator>westbestern</dc:creator>
      <dc:date>2021-11-10T20:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating two dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-two-dummy-variables/m-p/779646#M248352</link>
      <description>Your code looks correct then. You can check it though, using proc freq. &lt;BR /&gt;&lt;BR /&gt;proc freq data=data2;&lt;BR /&gt;table smoke_hx*ever_smoked1 / list;&lt;BR /&gt;table smoke_hx*ever_smoked2 / list;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 10 Nov 2021 20:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-two-dummy-variables/m-p/779646#M248352</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T20:25:09Z</dc:date>
    </item>
  </channel>
</rss>

