<?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: Create new age variable then create agegroups in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/120000#M33044</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi try:&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data test;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;set homewrk2.test;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;age=int((dov-dob)/365.25);&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;/*create age groups*/&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if age &amp;lt;= 12 then agegrp=1;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;else if 12 &amp;lt;= age &amp;lt; 20 then agegrp=2;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;else if age &amp;gt;=20 then agegrp=3;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Feb 2013 02:57:04 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2013-02-25T02:57:04Z</dc:date>
    <item>
      <title>Create new age variable then create agegroups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/119999#M33043</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 need to create an age variable based on date of birth ('dob') and another date ('dov'). Examples of how the numbers in dob and dov are displayed are: 5503, 6445, 16229, 16404.&lt;/P&gt;&lt;P&gt;How do I create a new variable 'age' based on the variables 'dob' and 'dov'? I'm not sure what format the dates or age has to be in, but age needs to be readable so that 12 = 12 years old, etc. Once I have the age variable in place, I will need to perform 2-way ANOVA to test for interaction to see if agegroup is an effect modifier. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not having luck creating the age variable, but did create agegroups (assuming I have age in place):&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;set homewrk2.test;&lt;/P&gt;&lt;P&gt;/*create age groups*/&lt;/P&gt;&lt;P&gt;if age &amp;lt;= 12 then agegrp=1;&lt;/P&gt;&lt;P&gt;else if 12 &amp;lt;= age &amp;lt; 20 then agegrp=2;&lt;/P&gt;&lt;P&gt;else if age &amp;gt;=20 then agegrp=3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any and all help and advice would be appreciated, in creating the new variable age and then creating agegroups!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Feb 2013 02:06:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/119999#M33043</guid>
      <dc:creator>SASstudent2013</dc:creator>
      <dc:date>2013-02-25T02:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create new age variable then create agegroups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/120000#M33044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi try:&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data test;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;set homewrk2.test;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;age=int((dov-dob)/365.25);&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;/*create age groups*/&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if age &amp;lt;= 12 then agegrp=1;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;else if 12 &amp;lt;= age &amp;lt; 20 then agegrp=2;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;else if age &amp;gt;=20 then agegrp=3;&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Feb 2013 02:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/120000#M33044</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-02-25T02:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create new age variable then create agegroups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/120001#M33045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. This seems to work! The only issue is that it is telling me that 'age' is uninitialized once I create the agegroups; log is below. Do you know if this note about it being uninitialized is an issue?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;115&amp;nbsp; data test;&lt;/P&gt;&lt;P&gt;116&amp;nbsp; set homewrk2.test;&lt;/P&gt;&lt;P&gt;117&amp;nbsp; /*create new variable for age*/&lt;/P&gt;&lt;P&gt;118&amp;nbsp; age=int((dov-dob)/365.25);&lt;/P&gt;&lt;P&gt;119&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;NOTE: There were 665 observations read from the data set HOMEWRK2.BONE.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.BONE has 665 observations and 10 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.92 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;120&amp;nbsp; data test;&lt;/P&gt;&lt;P&gt;121&amp;nbsp; set homewrk2.test;&lt;/P&gt;&lt;P&gt;122&amp;nbsp; /*create age groups so that group 1 = children under 12 years old, group 2 = children 12 or&lt;/P&gt;&lt;P&gt;122! older but younger than 20, group 3 = 20 or older*/&lt;/P&gt;&lt;P&gt;123&amp;nbsp; if age &amp;lt; 12 then agegrp=1;&lt;/P&gt;&lt;P&gt;124&amp;nbsp; else if 12 &amp;lt;= age &amp;lt; 20 then agegrp=2;&lt;/P&gt;&lt;P&gt;125&amp;nbsp; else if age &amp;gt;=20 then agegrp=3;&lt;/P&gt;&lt;P&gt;126&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Variable age is uninitialized.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Feb 2013 03:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/120001#M33045</guid>
      <dc:creator>SASstudent2013</dc:creator>
      <dc:date>2013-02-25T03:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create new age variable then create agegroups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/120002#M33046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Did you use dataset HOMEWRK2.BONE. or HOMEWRK2.test? It would be helpful if you post your code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Feb 2013 13:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/120002#M33046</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-02-25T13:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create new age variable then create agegroups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/120003#M33047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When it says in your log that "Age is uninitialized" what that means is that the variable "Age" does not exist in the dataset.&amp;nbsp; I don't know why the LOG always shows this note in blue, when it seems to me that it should be in big bold red letters, but so be it.&amp;nbsp; It is a problem because any calculations that you attempt on based on "Age" will result to missing (because there is no age...).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the example you posted above, it appears that the problem is because you're writing over the same dataset twice. (Although, as Linlin points out, it's a little hard to tell because your LOG notes reference a different dataset than what the code references...)&amp;nbsp; So ignoring the LOG notes that reference HOMEWRK2.BONE, what I see is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;--- you create a dataset WORK.TEST&lt;/P&gt;&lt;P&gt;set homewrk2.test;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;--- It is based off of HOMEWRK2.TEST&lt;/P&gt;&lt;P&gt;age=int((dov-dob)/365.25);&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;--- You create a new variable in WORK.TEST called "AGE"&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;--- You again create a dataset WORK.TEST, essentially writing over everything you just did. &lt;/P&gt;&lt;P&gt;set homewrk2.test;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;--- This is also based off of HOMEWRK2.TEST, ignoring everything you just did.&lt;/P&gt;&lt;P&gt;if age &amp;lt; 12 then agegrp=1; &amp;lt;--- SAS freaks out because HOMEWRK2.TEST does not have a variable called "AGE"&lt;/P&gt;&lt;P&gt;else if 12 &amp;lt;= age &amp;lt; 20 then agegrp=2;&lt;/P&gt;&lt;P&gt;else if age &amp;gt;=20 then agegrp=3;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;--- The end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So instead, try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;set homewrk2.test;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;age=int((dov-dob)/365.25);&amp;nbsp; &lt;/P&gt;&lt;P&gt;if age &amp;lt; 12 then agegrp=1; &lt;/P&gt;&lt;P&gt;else if 12 &amp;lt;= age &amp;lt; 20 then agegrp=2;&lt;/P&gt;&lt;P&gt;else if age &amp;gt;=20 then agegrp=3;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;--- The end&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 00:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-new-age-variable-then-create-agegroups/m-p/120003#M33047</guid>
      <dc:creator>TashaChapman</dc:creator>
      <dc:date>2013-02-26T00:22:14Z</dc:date>
    </item>
  </channel>
</rss>

