<?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 to create dummy variables - Categorical Variables in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/398034#M3500</link>
    <description>&lt;P&gt;Also note that once you add quotes, the exact spelling matters. &amp;nbsp;"COKE" is different than "Coke". &amp;nbsp;You may want to change the comparison:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if upcase(company) = "COKE" then CokeD=1; else CokeD=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2017 10:08:55 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-09-22T10:08:55Z</dc:date>
    <item>
      <title>How to create dummy variables - Categorical Variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/397990#M3496</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create dummy variables for companies in my data set. Unfortunately the output is all zeros.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WORK.IMPORT;&lt;BR /&gt;SET WORK.IMPORT;&lt;BR /&gt;IF COMPANY = COKE THEN COKED=1; ELSE COKED = 0;&lt;BR /&gt;IF COMPANY = KFC THEN KFCD=1; ELSE KFCD = 0;&lt;BR /&gt;IF COMPANY = PEPSI THEN PEPSID=1; ELSE PEPSID = 0;&lt;BR /&gt;IF COMPANY = NIKE THEN NIKED=1; ELSE NIKED = 0;&lt;BR /&gt;IF COMPANY = STARBUCKS THEN STARBUCKSD=1; ELSE STARBUCKSD = 0;&lt;BR /&gt;IF COMPANY = MCDONALD THEN MCDONALDD=1; ELSE MCDONALDD = 0;&lt;BR /&gt;IF COMPANY = HARDEES THEN HARDEESD=1; ELSE HARDEESD = 0;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;unfortunately the ouput for the dummy variables is all 0, so if the company is coke the output is also 0 and not 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't understand what is wrong, please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 05:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/397990#M3496</guid>
      <dc:creator>aalasady0</dc:creator>
      <dc:date>2017-09-22T05:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables - Categorical Variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/397994#M3497</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just put quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;IF COMPANY = &lt;STRONG&gt;"COKE"&lt;/STRONG&gt; THEN COKED=1; ELSE COKED = 0;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 05:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/397994#M3497</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2017-09-22T05:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables - Categorical Variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/398020#M3498</link>
      <description>&lt;P&gt;What&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42042"&gt;@stat_sas&lt;/a&gt;&amp;nbsp;says - basically what is happening in your code is that SAS assumes that COKE, NIKE etc are variables in the data set but once you add double quotes it takes them as string literals.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 08:36:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/398020#M3498</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-09-22T08:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables - Categorical Variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/398021#M3499</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you say&amp;nbsp;&lt;SPAN&gt;COMPANY = COKE&amp;nbsp; actually you compare 2 variables - COMPANY and COKE. If the variablke COKE is missing in your dataset you will notice a NOTE within the log :&amp;nbsp;Variable COKE&amp;nbsp;is uninitialized.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The solution has already been provided by&amp;nbsp;@stat_sas.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 08:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/398021#M3499</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2017-09-22T08:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables - Categorical Variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/398034#M3500</link>
      <description>&lt;P&gt;Also note that once you add quotes, the exact spelling matters. &amp;nbsp;"COKE" is different than "Coke". &amp;nbsp;You may want to change the comparison:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if upcase(company) = "COKE" then CokeD=1; else CokeD=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 10:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/398034#M3500</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-22T10:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables - Categorical Variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/398120#M3501</link>
      <description>&lt;P&gt;It might also help to describe how you are intending to use those dummy variables.&lt;/P&gt;
&lt;P&gt;A large number of the SAS procedures will create internal dummies when needed so additional variables are not needed.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 14:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-dummy-variables-Categorical-Variables/m-p/398120#M3501</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-22T14:48:43Z</dc:date>
    </item>
  </channel>
</rss>

