<?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 create dummy code matrices from all combinations of a set of stratifying variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-dummy-code-matrices-from-all-combinations-of-a-set-of/m-p/439170#M282373</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to SAS and I'm having a hard time dummy coding dummy variables. I have a 4 level categorical variables (level of education) and understand I should have 3 dummy variables, but that output codes 0 for levels 2 and 4. Should I include the 4th code, and if I do, how do I know which one is the reference variable. Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WORK.IMPORT1;&lt;BR /&gt;SET WORK.IMPORT;&lt;BR /&gt;IF _educag = 1 THEN educagd=1; ELSE educagd = 0;&lt;BR /&gt;IF _educag = 2 THEN educagd=1; ELSE educagd = 0;&lt;BR /&gt;IF _educag = 3 THEN educagd=1; ELSE educagd = 0;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2018 05:09:10 GMT</pubDate>
    <dc:creator>dhuerta</dc:creator>
    <dc:date>2018-02-22T05:09:10Z</dc:date>
    <item>
      <title>create dummy code matrices from all combinations of a set of stratifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-dummy-code-matrices-from-all-combinations-of-a-set-of/m-p/439170#M282373</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to SAS and I'm having a hard time dummy coding dummy variables. I have a 4 level categorical variables (level of education) and understand I should have 3 dummy variables, but that output codes 0 for levels 2 and 4. Should I include the 4th code, and if I do, how do I know which one is the reference variable. Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WORK.IMPORT1;&lt;BR /&gt;SET WORK.IMPORT;&lt;BR /&gt;IF _educag = 1 THEN educagd=1; ELSE educagd = 0;&lt;BR /&gt;IF _educag = 2 THEN educagd=1; ELSE educagd = 0;&lt;BR /&gt;IF _educag = 3 THEN educagd=1; ELSE educagd = 0;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 05:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-dummy-code-matrices-from-all-combinations-of-a-set-of/m-p/439170#M282373</guid>
      <dc:creator>dhuerta</dc:creator>
      <dc:date>2018-02-22T05:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: create dummy code matrices from all combinations of a set of stratifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-dummy-code-matrices-from-all-combinations-of-a-set-of/m-p/439195#M282374</link>
      <description>&lt;P&gt;Why do you need those dummy vars? Having a single variable with four distinct values is almost always easier to deal with, than four variables. Maybe adding some put-statements will help you understanding what happens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.import1;
  set work.import;
  if _educag = 1 then educagd=1; else educagd = 0;
  put educagd=;
  if _educag = 2 then educagd=1; else educagd = 0;
  put educagd=;
  if _educag = 3 then educagd=1; else educagd = 0;
  put educagd=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And please avoid coding in all upcase.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 08:31:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-dummy-code-matrices-from-all-combinations-of-a-set-of/m-p/439195#M282374</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-02-22T08:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: create dummy code matrices from all combinations of a set of stratifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-dummy-code-matrices-from-all-combinations-of-a-set-of/m-p/439265#M282375</link>
      <description>&lt;P&gt;Your code is creating only a single dummy variable named EDUCAGD.&amp;nbsp; You do assign it, and re-assign its value several times.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, you need to assign values to three different dummy variables:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;IF _educag = 1 THEN educagd1=1; ELSE educagd1 = 0;&lt;BR /&gt;IF _educag = 2 THEN educagd2=1; ELSE educagd2 = 0;&lt;BR /&gt;IF _educag = 3 THEN educagd3=1; ELSE educagd3 = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, most of the time it is not necessary to create these at all.&amp;nbsp; The procedure that you use might be able to create the right number of dummy variables automatically.&amp;nbsp; (See if the procedure you use will support a CLASS statement.)&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 13:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-dummy-code-matrices-from-all-combinations-of-a-set-of/m-p/439265#M282375</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-22T13:27:36Z</dc:date>
    </item>
  </channel>
</rss>

