<?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 in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-CReate-Dummy-Variables-in-SAS/m-p/599575#M173093</link>
    <description>&lt;P&gt;Thank you so much, I removed the $ from Sex input during one of my earlier experiments with the code to accomplish something different and clearly missed putting it back. I've been so frustrated with this code that I completely overlooked it, thank you.&lt;/P&gt;</description>
    <pubDate>Sat, 26 Oct 2019 21:57:56 GMT</pubDate>
    <dc:creator>pstarr</dc:creator>
    <dc:date>2019-10-26T21:57:56Z</dc:date>
    <item>
      <title>How to CReate Dummy Variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-CReate-Dummy-Variables-in-SAS/m-p/599570#M173090</link>
      <description>&lt;P&gt;We're doing Multiple Linear Regression in my statistics class. There's a lot of code snippets provided without context of what is happening and why. For this question on my homework, I'm assuming that we need to use dummy variables because the category is for Sex with the options being Male and Female as strings. I can't just put these into proc reg because it rejects the Sex variable as it is. I've been trying to create dummy variables with variations of the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data file;
infile '\\Client\C$\Users\st\Desktop\Statistics\TETwithoutHeaders.txt'
delimiter='09'x;
input ID LOGACT21 Dosage Sex;
IF Sex = "Male" THEN sexAsNum = 0; 
ELSE sexAsNum = 1;
proc print;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've also tried a provided code snippet from the professor in place of the if-else statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Do i=1 To _N_; If Sex="Male" then sexAsNum=1; else sexAsNum=0; end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of changing all of the "Male" rows to have a new column sexAsNum with the value of 1 and all "Female" rows to have the sexAsNum value of 0, the rows under the Sex column have had their values replaced with - and two new columns, i and sexAsNum, have been added. All of the rows of column i seem to have irrelevant incrementing and every sexAsNum value is 0 regardless of what Sex was previously.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone please tell me what I'm doing wrong?&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2019 21:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-CReate-Dummy-Variables-in-SAS/m-p/599570#M173090</guid>
      <dc:creator>pstarr</dc:creator>
      <dc:date>2019-10-26T21:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to CReate Dummy Variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-CReate-Dummy-Variables-in-SAS/m-p/599574#M173092</link>
      <description>&lt;P&gt;You read sex into a numeric variable in your input statement, so it cannot contain character values like "Male".&lt;/P&gt;
&lt;P&gt;Start by correctly reading the file, and then decide how to handle the data.&lt;/P&gt;
&lt;P&gt;If in doubt, post a few lines of your infile, using the {i} button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296957"&gt;@pstarr&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;We're doing Multiple Linear Regression in my statistics class. There's a lot of code snippets provided without context of what is happening and why. For this question on my homework, I'm assuming that we need to use dummy variables because the category is for Sex with the options being Male and Female as strings. I can't just put these into proc reg because it rejects the Sex variable as it is. I've been trying to create dummy variables with variations of the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data file;
infile '\\Client\C$\Users\st\Desktop\Statistics\TETwithoutHeaders.txt'
delimiter='09'x;
input ID LOGACT21 Dosage Sex;
IF Sex = "Male" THEN sexAsNum = 0; 
ELSE sexAsNum = 1;
proc print;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've also tried a provided code snippet from the professor in place of the if-else statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Do i=1 To _N_; If Sex="Male" then sexAsNum=1; else sexAsNum=0; end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of changing all of the "Male" rows to have a new column sexAsNum with the value of 1 and all "Female" rows to have the sexAsNum value of 0, the rows under the Sex column have had their values replaced with - and two new columns, i and sexAsNum, have been added. All of the rows of column i seem to have irrelevant incrementing and every sexAsNum value is 0 regardless of what Sex was previously.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could someone please tell me what I'm doing wrong?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2019 21:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-CReate-Dummy-Variables-in-SAS/m-p/599574#M173092</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-26T21:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to CReate Dummy Variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-CReate-Dummy-Variables-in-SAS/m-p/599575#M173093</link>
      <description>&lt;P&gt;Thank you so much, I removed the $ from Sex input during one of my earlier experiments with the code to accomplish something different and clearly missed putting it back. I've been so frustrated with this code that I completely overlooked it, thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2019 21:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-CReate-Dummy-Variables-in-SAS/m-p/599575#M173093</guid>
      <dc:creator>pstarr</dc:creator>
      <dc:date>2019-10-26T21:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to CReate Dummy Variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-CReate-Dummy-Variables-in-SAS/m-p/599582#M173099</link>
      <description>&lt;P&gt;There is absolutely no need to create dummy variables to do a regression. PROC GLM creates the dummy variables for you, so you don't have to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm data=file;
    class sex;
    model y = sex x1 x2 x3;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Don't waste your time creating dummy variables for regression.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2019 22:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-CReate-Dummy-Variables-in-SAS/m-p/599582#M173099</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-26T22:59:01Z</dc:date>
    </item>
  </channel>
</rss>

