<?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: calculate age from date in character format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-age-from-date-in-character-format/m-p/829817#M327873</link>
    <description>&lt;P&gt;the intck function takes a date not a string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test2;
set test1;
if ageu='Year' THEN NEW_AGE=AGE;
	else if ageu='Mon' THEN NEW_AGE=round(AGE/12, 0.01);
	else if ageu not in ('Year', 'Mon')  and RFICDTC ne '' and BRTHDTC ne '' then NEW_AGE=intck('year', input(RFICDTC,yymmdd10.), input(BRTHDTC,yymmdd10.));
	else new_age=.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;also notice that strings are case sensitive. You want 'Year' not 'year'&lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2022 08:25:20 GMT</pubDate>
    <dc:creator>rudfaden</dc:creator>
    <dc:date>2022-08-23T08:25:20Z</dc:date>
    <item>
      <title>calculate age from date in character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-age-from-date-in-character-format/m-p/829815#M327872</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;From the below data, I want to calculate age based on the condition like below&lt;/P&gt;
&lt;P&gt;if age unit is year, then new_Age=age&lt;/P&gt;
&lt;P&gt;if age unit is month, then new_age should be converted to year&lt;/P&gt;
&lt;P&gt;if age and unit is blank, then value of new_age will be calculated by subtracting brthdtc from rficdtc .&lt;/P&gt;
&lt;P&gt;When I write the logic, it is working but getting below message in log file. can you please help me what mistake I am doing&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help me how to proceed. Below is the sample of data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
input pid age ageu $ rficdtc $19. brthdtc $10. ;
cards;
101 23 Year 2012-12-09T10:51:00 1987-07-19
102 230 Mon 1999-12-11 1987-07-19
103 113 Mon 1995-12-11 1992-07-19
104 . . 2016-12-09T10:51:00 1995-07-19
;
run;
proc sql;
create table test1 as
select pid, age, ageu,
put(input(substr(strip(rficdtc),1,10),yymmdd10.),yymmdd10.) as rficdtc,
strip(brthdtc) as brthdtc 
from test;
quit;
data test2;
set test1;
if ageu='year' THEN NEW_AGE=AGE;
	else if ageu='Mon' THEN NEW_AGE=round(AGE/12, 0.01);
	else if ageu not in ('year', 'Mon')  and RFICDTC ne '' and BRTHDTC ne '' then NEW_AGE=intck('year', RFICDTC, BRTHDTC);
	else new_age=.;
run;





&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Aug 2022 08:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-age-from-date-in-character-format/m-p/829815#M327872</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2022-08-23T08:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: calculate age from date in character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-age-from-date-in-character-format/m-p/829817#M327873</link>
      <description>&lt;P&gt;the intck function takes a date not a string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test2;
set test1;
if ageu='Year' THEN NEW_AGE=AGE;
	else if ageu='Mon' THEN NEW_AGE=round(AGE/12, 0.01);
	else if ageu not in ('Year', 'Mon')  and RFICDTC ne '' and BRTHDTC ne '' then NEW_AGE=intck('year', input(RFICDTC,yymmdd10.), input(BRTHDTC,yymmdd10.));
	else new_age=.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;also notice that strings are case sensitive. You want 'Year' not 'year'&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 08:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-age-from-date-in-character-format/m-p/829817#M327873</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2022-08-23T08:25:20Z</dc:date>
    </item>
  </channel>
</rss>

