<?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: Construct the new variable date in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619570#M19409</link>
    <description>&lt;P&gt;When I run the code you just showed with INTCK, I get meaningful age values, and I do not get the values you show.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe you have committed a typing error, and your PROC PRINT should be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC PRINT DATA=Dates; /* &amp;lt;== note the S on the end is needed here&amp;nbsp;*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jan 2020 20:01:46 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-01-23T20:01:46Z</dc:date>
    <item>
      <title>Construct the new variable date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619530#M19402</link>
      <description>&lt;P&gt;I am creating the new variable - date. I am not too sure what is wrong when the age comes out quite strange.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA Date;
	INPUT month 1-2 year 4-7 day 9-10;
	bday=MDY(month,day,year);
	age=INT(MDY(1,1,2008)-bday/365.25);
CARDS;
6  1918 12
7  1948 11
1  1960  1
10 1970 15 
12 1971 10 
;
RUN;
ODS RTF FILE="/folders/myfolders/Lecture_ Resources/Chapter4/Chap4p25";
PROC PRINT DATA=Date;
	FORMAT bday date9. age;
RUN;
ODS RTF CLOSE;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-01-24 at 3.50.20 AM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35572i60A27F5DF953FD64/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-01-24 at 3.50.20 AM.png" alt="Screen Shot 2020-01-24 at 3.50.20 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Can anyone tell me what 's wrong with my code?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 14:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619530#M19402</guid>
      <dc:creator>kngu022</dc:creator>
      <dc:date>2020-01-23T14:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Construct the new variable date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619534#M19403</link>
      <description>&lt;P&gt;Plz check the parenthesis&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a correction&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	age=INT((MDY(1,1,2008)-bday)/365.25);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jan 2020 14:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619534#M19403</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-23T14:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Construct the new variable date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619537#M19404</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Order of operations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age=INT((MDY(1,1,2008)-bday)/365.25);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jan 2020 15:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619537#M19404</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-01-23T15:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Construct the new variable date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619538#M19405</link>
      <description>&lt;P&gt;You have made a math error, which extra parentheses will fix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age=INT((MDY(1,1,2008)-bday)/365.25);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By the way, a better method of accounting for leap years is the INTCK function, or the YRDIF function.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 15:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619538#M19405</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-23T15:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Construct the new variable date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619542#M19406</link>
      <description>&lt;P&gt;Try this data step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Date;
	INPUT month 1-2 year 4-7 day 9-10;
	age=intck('year', MDY(month,day,year), MDY(1,1,2008));
CARDS;
6  1918 12
7  1948 11
1  1960  1
10 1970 15 
12 1971 10 
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 15:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619542#M19406</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2020-01-23T15:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Construct the new variable date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619566#M19408</link>
      <description>&lt;P&gt;After changed the code as above, the result comes out still the same. I doubt that my code still has some errors. Could you please show&lt;/P&gt;&lt;P&gt;me please?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA dates;
    INPUT  month 1-2 year 4-7 day 9-10;
    bday=MDY(month,day,year);
	age=intck('year', MDY(month,day,year), MDY(1,1,2008));
	
CARDS;
 6   18	12
 6 1918 12
 7 1948 11
 1 1960  1
10 1970 15
12 1971 10
;
RUN;
ODS RTF FILE="/folders/myfolders/Lecture_ Resources/Chapter4/Chap4p25";
PROC PRINT DATA=Date;
	FORMAT bday date8. age;
RUN;
ODS RTF CLOSE;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-01-24 at 4.39.56 AM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35574i5E6A594BF4D2219D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-01-24 at 4.39.56 AM.png" alt="Screen Shot 2020-01-24 at 4.39.56 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 15:41:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619566#M19408</guid>
      <dc:creator>kngu022</dc:creator>
      <dc:date>2020-01-23T15:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Construct the new variable date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619570#M19409</link>
      <description>&lt;P&gt;When I run the code you just showed with INTCK, I get meaningful age values, and I do not get the values you show.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe you have committed a typing error, and your PROC PRINT should be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC PRINT DATA=Dates; /* &amp;lt;== note the S on the end is needed here&amp;nbsp;*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 20:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619570#M19409</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-23T20:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Construct the new variable date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619739#M19435</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/306646"&gt;@kngu022&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In regards of calculating age: Why not use the YRDIF() function which specifically provides an argument to calculate the age.&lt;/P&gt;
&lt;P&gt;From the docu found &lt;A href="https://go.documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1pmmr2dtec32an1vbsqmm3abil5.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p0f4lsrlxkerlnn1u7pqrin7t9lx" target="_self"&gt;here&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;Example 2: Calculating a Person’s Age
You can calculate a person’s age by using three arguments in the YRDIF function. The third argument, basis, must have a value of AGE:

data _null_;
   sdate='16oct1998'd;
   edate='16feb2010'd;
   age=yrdif(sdate, edate, 'AGE');
   put age= 'years';
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jan 2020 02:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619739#M19435</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-01-24T02:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Construct the new variable date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619752#M19441</link>
      <description>&lt;P&gt;Your code is printing a different dataset than the data step is creating.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA dates;
...
PROC PRINT DATA=Date;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jan 2020 03:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Construct-the-new-variable-date/m-p/619752#M19441</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-24T03:26:10Z</dc:date>
    </item>
  </channel>
</rss>

