<?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 How to derive age variables without the diagnostic variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-derive-age-variables-without-the-diagnostic-variable/m-p/872434#M38681</link>
    <description>FILENAME REFFILE '/home/u63367626/PATIENTS/Patients.xlsx';&lt;BR /&gt;&lt;BR /&gt;PROC IMPORT DATAFILE=REFFILE&lt;BR /&gt;DBMS=XLSX&lt;BR /&gt;OUT=WORK.patt;&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;PROC CONTENTS DATA=WORK.patt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data patt1;&lt;BR /&gt;set patt;&lt;BR /&gt;format dob1 date9.;&lt;BR /&gt;&lt;BR /&gt;dob=compress(cat(month,'/',day,'/',year));&lt;BR /&gt;dob1=input(dob,mmddyy10.);&lt;BR /&gt;&lt;BR /&gt;age = (dob1)/365.;&lt;BR /&gt;&lt;BR /&gt;run;</description>
    <pubDate>Thu, 27 Apr 2023 03:46:05 GMT</pubDate>
    <dc:creator>Sammy_G</dc:creator>
    <dc:date>2023-04-27T03:46:05Z</dc:date>
    <item>
      <title>How to derive age variables without the diagnostic variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-derive-age-variables-without-the-diagnostic-variable/m-p/872434#M38681</link>
      <description>FILENAME REFFILE '/home/u63367626/PATIENTS/Patients.xlsx';&lt;BR /&gt;&lt;BR /&gt;PROC IMPORT DATAFILE=REFFILE&lt;BR /&gt;DBMS=XLSX&lt;BR /&gt;OUT=WORK.patt;&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;PROC CONTENTS DATA=WORK.patt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data patt1;&lt;BR /&gt;set patt;&lt;BR /&gt;format dob1 date9.;&lt;BR /&gt;&lt;BR /&gt;dob=compress(cat(month,'/',day,'/',year));&lt;BR /&gt;dob1=input(dob,mmddyy10.);&lt;BR /&gt;&lt;BR /&gt;age = (dob1)/365.;&lt;BR /&gt;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 27 Apr 2023 03:46:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-derive-age-variables-without-the-diagnostic-variable/m-p/872434#M38681</guid>
      <dc:creator>Sammy_G</dc:creator>
      <dc:date>2023-04-27T03:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive age variables without the diagnostic variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-derive-age-variables-without-the-diagnostic-variable/m-p/872437#M38682</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your Month, Day and Year variables are numeric then use the MDY function to get a SAS date value:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dob = mdy(month, day, year);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AGE requires a date to report the the age as of.&amp;nbsp; There is a SAS function YRDIF that takes two dates and will return years and fraction of a year as a decimal value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Age_today = yrdif(dob, Today() );&lt;/P&gt;
&lt;P&gt;Better would be to pick a date for an "age as of" such as this to calculate an age as of the first day of 2023. Any date you use with a literal value is ddMONyyyy in quotes followed by the d which tells SAS that you want the SAS date value.:&lt;/P&gt;
&lt;P&gt;Age = yrdif(dob, '01JAN2023'd);&lt;/P&gt;
&lt;P&gt;If you do not want the decimal portion then use the Floor function to round down to the integer.&lt;/P&gt;
&lt;P&gt;Age_today = floor(yrdif(dob, Today() ));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS dates are the number of days since 1 Jan 1960 so dividing by 365 would give you close to the number of years since 1 Jan 1960 but only for those born after that date. Anyone born before that day would have a negative "age".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 04:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-derive-age-variables-without-the-diagnostic-variable/m-p/872437#M38682</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-27T04:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive age variables without the diagnostic variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-derive-age-variables-without-the-diagnostic-variable/m-p/872579#M38685</link>
      <description>Thank you very much, you were really helpful.</description>
      <pubDate>Thu, 27 Apr 2023 13:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-derive-age-variables-without-the-diagnostic-variable/m-p/872579#M38685</guid>
      <dc:creator>Sammy_G</dc:creator>
      <dc:date>2023-04-27T13:59:37Z</dc:date>
    </item>
  </channel>
</rss>

