<?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: find a age from character and numeric values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810232#M319508</link>
    <description>yes the hepb_date is the date i want to know the age, and I only have the year of birth</description>
    <pubDate>Wed, 27 Apr 2022 17:13:00 GMT</pubDate>
    <dc:creator>Cooksam13</dc:creator>
    <dc:date>2022-04-27T17:13:00Z</dc:date>
    <item>
      <title>find a age from character and numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810224#M319505</link>
      <description>&lt;P&gt;I need to find the age at a test was given.&amp;nbsp;&lt;/P&gt;&lt;P&gt;CBDOB is the birth date&lt;/P&gt;&lt;P&gt;and hepb_date is the date the test was given&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Variable Type Len Format Informat Label&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CDOB&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;hepb_date&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;$5.&lt;/TD&gt;&lt;TD&gt;$5.&lt;/TD&gt;&lt;TD&gt;hepb_date&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but some of the dates look like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cooksam13_0-1651078123453.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70914iB55AA311142A4190/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cooksam13_0-1651078123453.png" alt="Cooksam13_0-1651078123453.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;or some look like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cooksam13_1-1651078277597.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70915i513C17D5D471C8D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cooksam13_1-1651078277597.png" alt="Cooksam13_1-1651078277597.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;can you help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 16:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810224#M319505</guid>
      <dc:creator>Cooksam13</dc:creator>
      <dc:date>2022-04-27T16:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: find a age from character and numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810227#M319506</link>
      <description>&lt;P&gt;Looks like imported data from an Excel spreadsheet.&amp;nbsp; One that had a column where some of the cells where character strings and some where dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To convert that strings into dates first convert them into numbers, then adjust the number for difference in how Excel and SAS count days.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  if indexc(hepb_date,'/') then year=input(hepb_date,4.);
  else  date = input(hepb_date,??32.)
  if not missing(date) then do;
    date=date+'30DEC1899'd ;
    year=year(date);
  end;
  format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have numeric DATE values or at least numeric YEAR value now you can try to calculate an AGE.&lt;/P&gt;
&lt;P&gt;Is HEBP_DATE the day that you want to know the age for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Do you only have year of birth?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Without full dates for both ends of the interval you can only get an estimate of the age.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 17:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810227#M319506</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-27T17:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: find a age from character and numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810232#M319508</link>
      <description>yes the hepb_date is the date i want to know the age, and I only have the year of birth</description>
      <pubDate>Wed, 27 Apr 2022 17:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810232#M319508</guid>
      <dc:creator>Cooksam13</dc:creator>
      <dc:date>2022-04-27T17:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: find a age from character and numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810467#M319599</link>
      <description>&lt;P&gt;now Im having trouble with the other side of things&lt;/P&gt;&lt;P&gt;I am still trying to find the age from hepb_date and the CDOB date&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the CDOB is in two different formats and i don't know how to universalize them, all i need is the year because I can use the year from the new hepb_date variable that is now "year" as you (&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&amp;nbsp;)suggested.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cooksam13_0-1651173216104.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70961iBD19A5449D462E54/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cooksam13_0-1651173216104.png" alt="Cooksam13_0-1651173216104.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 19:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810467#M319599</guid>
      <dc:creator>Cooksam13</dc:creator>
      <dc:date>2022-04-28T19:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: find a age from character and numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810468#M319600</link>
      <description>&lt;P&gt;It is hard to tell what you actually have in the data from looking a PHOTOGRAPH of the data.&lt;/P&gt;
&lt;P&gt;Is CDOB also character?&lt;BR /&gt;Then use the SAME METHOD to convert it to a number.&amp;nbsp; Just adjust for the style of the strings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  if index(cdob,'/') then do;
     dob=input(cdob,mmddyy10.);
     dobyr=year(dob);
  end;
  else dobyr=input(cdob,4.);
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now if you have both DOBYR and YEAR as numbers to find an estimate of the age just subtract them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age = year - dobyr ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 19:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-a-age-from-character-and-numeric-values/m-p/810468#M319600</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-28T19:40:22Z</dc:date>
    </item>
  </channel>
</rss>

