<?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 Age Groups from Age Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-Age-Groups-from-Age-Variable/m-p/416475#M280258</link>
    <description>&lt;P&gt;Please help me with the following code, I'm using SAS 9.3. I'm trying to create age categories for children:&lt;/P&gt;&lt;P&gt;Birth up to 1&lt;/P&gt;&lt;P&gt;1-5 years old&lt;/P&gt;&lt;P&gt;6-12 years old&lt;/P&gt;&lt;P&gt;13 up to 18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new; set old;&lt;BR /&gt;if subject_age=0 or&amp;nbsp;age_unit in ("Hours","Days","Months") then age_cat=1;&lt;BR /&gt;if 1&amp;lt;=&lt;SPAN&gt;subject_age&lt;/SPAN&gt;&amp;lt;=5 and &lt;SPAN&gt;age_unit&lt;/SPAN&gt; in ("Years") then age_cat=2;&lt;BR /&gt;if 6&amp;lt;=&lt;SPAN&gt;subject_age&lt;/SPAN&gt;&amp;lt;=12 and &lt;SPAN&gt;age_unit&amp;nbsp;&lt;/SPAN&gt;in ("Years") then age_cat=3;&lt;BR /&gt;if 13&amp;lt;=&lt;SPAN&gt;subject_age&lt;/SPAN&gt;&amp;lt;=17 and &lt;SPAN&gt;age_unit&lt;/SPAN&gt; in ("Years") then age_cat=4;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each time I run the code, all observations are coded as age_cat=1&lt;/P&gt;</description>
    <pubDate>Mon, 27 Nov 2017 17:54:36 GMT</pubDate>
    <dc:creator>katesmith</dc:creator>
    <dc:date>2017-11-27T17:54:36Z</dc:date>
    <item>
      <title>Creating Age Groups from Age Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Age-Groups-from-Age-Variable/m-p/416475#M280258</link>
      <description>&lt;P&gt;Please help me with the following code, I'm using SAS 9.3. I'm trying to create age categories for children:&lt;/P&gt;&lt;P&gt;Birth up to 1&lt;/P&gt;&lt;P&gt;1-5 years old&lt;/P&gt;&lt;P&gt;6-12 years old&lt;/P&gt;&lt;P&gt;13 up to 18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new; set old;&lt;BR /&gt;if subject_age=0 or&amp;nbsp;age_unit in ("Hours","Days","Months") then age_cat=1;&lt;BR /&gt;if 1&amp;lt;=&lt;SPAN&gt;subject_age&lt;/SPAN&gt;&amp;lt;=5 and &lt;SPAN&gt;age_unit&lt;/SPAN&gt; in ("Years") then age_cat=2;&lt;BR /&gt;if 6&amp;lt;=&lt;SPAN&gt;subject_age&lt;/SPAN&gt;&amp;lt;=12 and &lt;SPAN&gt;age_unit&amp;nbsp;&lt;/SPAN&gt;in ("Years") then age_cat=3;&lt;BR /&gt;if 13&amp;lt;=&lt;SPAN&gt;subject_age&lt;/SPAN&gt;&amp;lt;=17 and &lt;SPAN&gt;age_unit&lt;/SPAN&gt; in ("Years") then age_cat=4;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each time I run the code, all observations are coded as age_cat=1&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 17:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Age-Groups-from-Age-Variable/m-p/416475#M280258</guid>
      <dc:creator>katesmith</dc:creator>
      <dc:date>2017-11-27T17:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Age Groups from Age Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Age-Groups-from-Age-Variable/m-p/416476#M280259</link>
      <description>&lt;P&gt;Please post some sample data, specifically ones that replicate your issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that this does not need to be real data but should reflect your situation.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 17:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Age-Groups-from-Age-Variable/m-p/416476#M280259</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-27T17:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Age Groups from Age Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Age-Groups-from-Age-Variable/m-p/416477#M280260</link>
      <description>&lt;P&gt;I made up some data, and I'm not having this problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us (part of) your data.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 18:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Age-Groups-from-Age-Variable/m-p/416477#M280260</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-27T18:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Age Groups from Age Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Age-Groups-from-Age-Variable/m-p/416478#M280261</link>
      <description>&lt;P&gt;Almost anything involving age or date-duration elements it is often best practice to turn things into a standard unit, all days, weeks, months what have you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your references two variables, subject_age and&amp;nbsp;age_unit,&amp;nbsp;but you do not show any example data values. You may want to provide some examples that are assigned age_cat1 that you think are incorrect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With some of my dummy data I do not get any unexpected results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 18:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Age-Groups-from-Age-Variable/m-p/416478#M280261</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-27T18:06:20Z</dc:date>
    </item>
  </channel>
</rss>

