<?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 change a continuous variable to a categorical variable? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215176#M5185</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Formats work. Your code seems to have an extra line whose purpose I don't seem to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;age=newage;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems to me to be extraneous.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You also need to use something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if age&amp;gt;=15 and age&amp;lt;=18 then newage=1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But to answer your question in a more broad sense, I know people have done this on occasion, but the idea of changing a continuous variable into a category just so you can perform a chi-squared test is inefficient. Better you should use all the information you have in your analysis, which requires you to treat age as a continuous variable which should provide a more powerful, and then the chi-squared test is inappropriate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Apr 2015 16:54:56 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2015-04-02T16:54:56Z</dc:date>
    <item>
      <title>How to change a continuous variable to a categorical variable?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215175#M5184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;I was wanting to know how to make sure to change a continuous variable into a categorical variable for chi square analysis. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would I use proc format or if then statements? I feel like if I use proc format I won't be able to do chi square statistics because it would make the numbers categorized into characters for a variable like age for example. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If then statements make a bit more sense renaming a new variable, in order to use in chi square analysis. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data example1; &lt;/P&gt;&lt;P&gt;set example;&lt;/P&gt;&lt;P&gt;age=newage;&lt;/P&gt;&lt;P&gt;If age= 15-18 then newage= 1;&lt;/P&gt;&lt;P&gt;If age=19-27 then new age =2;&lt;/P&gt;&lt;P&gt;if age &amp;gt; 27 then new age=3 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And new age would be the variable I would use in chi square analysis. Is this correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any syntax missing from this code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Apr 2015 16:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215175#M5184</guid>
      <dc:creator>Macyhe22</dc:creator>
      <dc:date>2015-04-02T16:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a continuous variable to a categorical variable?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215176#M5185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Formats work. Your code seems to have an extra line whose purpose I don't seem to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;age=newage;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems to me to be extraneous.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You also need to use something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if age&amp;gt;=15 and age&amp;lt;=18 then newage=1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But to answer your question in a more broad sense, I know people have done this on occasion, but the idea of changing a continuous variable into a category just so you can perform a chi-squared test is inefficient. Better you should use all the information you have in your analysis, which requires you to treat age as a continuous variable which should provide a more powerful, and then the chi-squared test is inappropriate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Apr 2015 16:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215176#M5185</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-04-02T16:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a continuous variable to a categorical variable?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215177#M5186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To expand on Paige's comments:&lt;/P&gt;&lt;P&gt;Create a custom format such as:&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;value myagegroup&lt;/P&gt;&lt;P&gt;15 - 18 = '15 to 18 years'&lt;/P&gt;&lt;P&gt;19 - 27 = '19 to 27 years'&lt;/P&gt;&lt;P&gt;28 - high = '28 and older'&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Then in the code you are running the analysis on you don't need to create a new variable, use AGE and add as statement:&lt;/P&gt;&lt;P&gt;format age myagegroup. ;&lt;/P&gt;&lt;P&gt;This will create the groups to be used by the chi-square AND get useable value labels.&lt;/P&gt;&lt;P&gt;Note: if you have ages less than 15 then each age would appear as a separate group.&lt;/P&gt;&lt;P&gt;One nice thing about this approach is when someone asks "what happens if we use 15-23, 24-28 and then larger you only need to create a new format, not another variable. Also if you create output datasets such as with proc freq you will get one value, usually the lowest value that actually appears in the group for the formatted variable in the output.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Apr 2015 18:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215177#M5186</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-04-02T18:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a continuous variable to a categorical variable?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215178#M5187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both for your assistance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Apr 2015 13:58:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215178#M5187</guid>
      <dc:creator>Macyhe22</dc:creator>
      <dc:date>2015-04-05T13:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a continuous variable to a categorical variable?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215179#M5188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much for the detailed information. I appreciate it greatly!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Apr 2015 14:00:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215179#M5188</guid>
      <dc:creator>Macyhe22</dc:creator>
      <dc:date>2015-04-05T14:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a continuous variable to a categorical variable?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215180#M5189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! I didn't know you could reduce the strength of the analysis by categorizing variables. I will look into other bivariate analysis tests. Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Apr 2015 14:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-continuous-variable-to-a-categorical-variable/m-p/215180#M5189</guid>
      <dc:creator>Macyhe22</dc:creator>
      <dc:date>2015-04-05T14:01:50Z</dc:date>
    </item>
  </channel>
</rss>

