<?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 AGE calculation  with yrdif in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651066#M195296</link>
    <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need ahelp with figuring out this error in age calculations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First service date and date of birth are coming as&amp;nbsp; DATETIME20 format like below examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FSTSRVDT&amp;nbsp; &amp;nbsp; = 07OCT2019:00:00:00&lt;/P&gt;&lt;P&gt;bth_dt&amp;nbsp; =&amp;nbsp; 21APR1950:00:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is my query -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table age_threshold_claims as select&lt;BR /&gt;claim,&lt;BR /&gt;FSTSRVDT,&lt;BR /&gt;bth_dt,&lt;BR /&gt;case when&lt;BR /&gt;yrdif(datepart(bth_dt),datepart(FSTSRVDT),'AGE') &amp;lt;=18 then 'Y' else '' end as tag_it&lt;BR /&gt;from SAS_dataset&lt;BR /&gt;;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error :&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Invalid (or missing) arguments to the DATEPART function have caused the function to return a missing value.&lt;BR /&gt;NOTE: Invalid argument to function YRDIF. Missing values may be generated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ana&lt;/P&gt;</description>
    <pubDate>Wed, 27 May 2020 12:49:18 GMT</pubDate>
    <dc:creator>SASAna</dc:creator>
    <dc:date>2020-05-27T12:49:18Z</dc:date>
    <item>
      <title>AGE calculation  with yrdif</title>
      <link>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651066#M195296</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need ahelp with figuring out this error in age calculations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First service date and date of birth are coming as&amp;nbsp; DATETIME20 format like below examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FSTSRVDT&amp;nbsp; &amp;nbsp; = 07OCT2019:00:00:00&lt;/P&gt;&lt;P&gt;bth_dt&amp;nbsp; =&amp;nbsp; 21APR1950:00:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is my query -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table age_threshold_claims as select&lt;BR /&gt;claim,&lt;BR /&gt;FSTSRVDT,&lt;BR /&gt;bth_dt,&lt;BR /&gt;case when&lt;BR /&gt;yrdif(datepart(bth_dt),datepart(FSTSRVDT),'AGE') &amp;lt;=18 then 'Y' else '' end as tag_it&lt;BR /&gt;from SAS_dataset&lt;BR /&gt;;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error :&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Invalid (or missing) arguments to the DATEPART function have caused the function to return a missing value.&lt;BR /&gt;NOTE: Invalid argument to function YRDIF. Missing values may be generated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ana&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2020 12:49:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651066#M195296</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2020-05-27T12:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: AGE calculation  with yrdif</title>
      <link>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651086#M195307</link>
      <description>&lt;P&gt;With data as you described, it works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sas_dataset;
input claim (FSTSRVDT bth_dt) (:datetime18.);
format FSTSRVDT bth_dt datetime19.;
datalines;
1 07OCT2019:00:00:00 21APR1950:00:00:00
;

proc sql;
create table age_threshold_claims as select
claim,
FSTSRVDT,
bth_dt,
case when
yrdif(datepart(bth_dt),datepart(FSTSRVDT),'AGE') &amp;lt;=18 then 'Y' else '' end as tag_it
from SAS_dataset
;
Quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 73         data sas_dataset;
 74         input claim (FSTSRVDT bth_dt) (:datetime18.);
 75         format FSTSRVDT bth_dt datetime19.;
 76         datalines;
 
 NOTE: The data set WORK.SAS_DATASET has 1 observations and 3 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 78         ;
 79         
 80         proc sql;
 81         create table age_threshold_claims as select
 82         claim,
 83         FSTSRVDT,
 84         bth_dt,
 85         case when
 86         yrdif(datepart(bth_dt),datepart(FSTSRVDT),'AGE') &amp;lt;=18 then 'Y' else '' end as tag_it
 87         from SAS_dataset
 88         ;
 NOTE: Table WORK.AGE_THRESHOLD_CLAIMS created, with 1 rows and 4 columns.
 
 89         Quit;
 NOTE:  Verwendet wurde: PROZEDUR SQL - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.01 seconds
&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 May 2020 13:35:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651086#M195307</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-27T13:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: AGE calculation  with yrdif</title>
      <link>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651094#M195313</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/86567"&gt;@SASAna&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Missing values of &lt;FONT face="courier new,courier"&gt;bth_dt&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;FSTSRVDT&lt;/FONT&gt; would cause these notes in the log. In this case you can avoid the notes by handling missing values explicitly, e.g., check for missings in a first WHEN condition and assign a missing value to &lt;FONT face="courier new,courier"&gt;tag_it&lt;/FONT&gt;, if any:&lt;/P&gt;
&lt;PRE&gt;case &lt;FONT color="#00CCFF"&gt;&lt;STRONG&gt;when nmiss(bth_dt, FSTSRVDT) then ' '&lt;/STRONG&gt;&lt;/FONT&gt;
     when yrdif(...&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2020 13:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651094#M195313</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-05-27T13:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: AGE calculation  with yrdif</title>
      <link>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651095#M195314</link>
      <description>&lt;P&gt;You may want to see if you have missing values for either of the two variables. Might as well checi if the bth_dt is later than the fstsrvdt as well since negative ages tend to indicate other data issues.&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   where missing(fstsrvdt) or missing(bth_dt) or (bth_dt &amp;gt; fstsrvdt);
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 May 2020 14:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651095#M195314</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-27T14:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: AGE calculation  with yrdif</title>
      <link>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651121#M195323</link>
      <description>Thank you. I found some missing Date of birth values whoch was triggering that Note/Warning.&lt;BR /&gt;&lt;BR /&gt;Thanks again,&lt;BR /&gt;Ana</description>
      <pubDate>Wed, 27 May 2020 15:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651121#M195323</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2020-05-27T15:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: AGE calculation  with yrdif</title>
      <link>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651122#M195324</link>
      <description>Thank you for testing. It was the missing values in the data.</description>
      <pubDate>Wed, 27 May 2020 15:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/AGE-calculation-with-yrdif/m-p/651122#M195324</guid>
      <dc:creator>SASAna</dc:creator>
      <dc:date>2020-05-27T15:54:03Z</dc:date>
    </item>
  </channel>
</rss>

