<?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: Date format sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641884#M191408</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264213"&gt;@mariamon0&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please provide some sample data and specify variable types (character / numeric ) ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&lt;/P&gt;</description>
    <pubDate>Wed, 22 Apr 2020 11:33:12 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-04-22T11:33:12Z</dc:date>
    <item>
      <title>Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641883#M191407</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to calculate age based on the date they came for a visit (date0) and their date of birth (dob0)&lt;/P&gt;
&lt;P&gt;aget=(date0)-(dob0)/365.25;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this calculated age is not working. Do I need to formate anything?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 11:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641883#M191407</guid>
      <dc:creator>mariamon0</dc:creator>
      <dc:date>2020-04-22T11:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641884#M191408</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264213"&gt;@mariamon0&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please provide some sample data and specify variable types (character / numeric ) ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 11:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641884#M191408</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-04-22T11:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641886#M191409</link>
      <description>This code should work, unless there is no issue with the date0 or dob0 variables. Could you please check if the date variables are numeric, please post the sample data to understand the query and help you better.</description>
      <pubDate>Wed, 22 Apr 2020 11:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641886#M191409</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-04-22T11:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641888#M191410</link>
      <description>&lt;P&gt;The date variables are in date format:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;visit date: 1/25/2016&lt;/P&gt;
&lt;P&gt;date of birth: 2/17/1940&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how do I change the format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 11:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641888#M191410</guid>
      <dc:creator>mariamon0</dc:creator>
      <dc:date>2020-04-22T11:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641889#M191411</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264213"&gt;@mariamon0&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to calculate age based on the date they came for a visit (date0) and their date of birth (dob0)&lt;/P&gt;
&lt;P&gt;aget=(date0)-(dob0)/365.25;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this calculated age is not working. Do I need to formate anything?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Formatting doesn't change the math. It only changes the appearance of a number. Also, to compute age you can use the INTCK function or the YRDIF function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But really, you should tell us more than just "not working". You should show us the LOG (code plus warning and error messages, do not chop anything out), and a portion of your data. This will provide sufficient information so we can diagnose the problems. Saying "not working" tells us nothing.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 11:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641889#M191411</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-22T11:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641891#M191413</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264213"&gt;@mariamon0&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The date variables are in date format:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;visit date: 1/25/2016&lt;/P&gt;
&lt;P&gt;date of birth: 2/17/1940&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how do I change the format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Formatting doesn't change the math. Are these numeric, or character (text), according to PROC CONTENTS???&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 11:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641891#M191413</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-22T11:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641893#M191414</link>
      <description>&lt;P&gt;I'm not getting whole numbers when I do a proc print of aget. The log appears completely fine. Both date of birth and date visit are numeric variables&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 11:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641893#M191414</guid>
      <dc:creator>mariamon0</dc:creator>
      <dc:date>2020-04-22T11:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641896#M191417</link>
      <description>&lt;P&gt;Yes, your formula doesn't produce whole numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the &lt;A href="https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm&amp;amp;locale=en" target="_self"&gt;INTCK()&lt;/A&gt; function or the &lt;A href="https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p1pmmr2dtec32an1vbsqmm3abil5.htm&amp;amp;locale=en" target="_self"&gt;YRDIF()&lt;/A&gt; function, you get whole numbers.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 12:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641896#M191417</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-22T12:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641897#M191418</link>
      <description>&lt;P&gt;What would the code look like for that?&lt;/P&gt;
&lt;P&gt;my date of birth variable is v_dob_0&lt;/P&gt;
&lt;P&gt;and my visit date variable is v_date_0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 12:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641897#M191418</guid>
      <dc:creator>mariamon0</dc:creator>
      <dc:date>2020-04-22T12:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641902#M191419</link>
      <description>&lt;P&gt;you can try the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume that the variables are character, so converting them to numeric&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date0:mmddyy10. dob0:mmddyy10.;
aget=(date0-dob0)/365.25;
cards;
1/25/2016 2/17/1940
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 12:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641902#M191419</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-04-22T12:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641903#M191420</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264213"&gt;@mariamon0&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What would the code look like for that?&lt;/P&gt;
&lt;P&gt;my date of birth variable is v_dob_0&lt;/P&gt;
&lt;P&gt;and my visit date variable is v_date_0&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The documentation I linked to shows simple examples.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;To correct an earlier statement I made, YRDIF does not return an integer. INTCK does return an integer.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 12:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641903#M191420</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-22T12:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641920#M191425</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&amp;nbsp;has given you the correct formula.&amp;nbsp; The formula you originally used was incorrect:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;aget=(date0)-(dob0)/365.25;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using your formula, SAS would perform the division first, then the subtraction.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 13:16:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641920#M191425</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-04-22T13:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: Date format sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641975#M191450</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264213"&gt;@mariamon0&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm not getting whole numbers when I do a proc print of aget. The log appears completely fine. Both date of birth and date visit are numeric variables&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please explain why with a formula like this you expected integers:&lt;/P&gt;
&lt;PRE&gt;aget=(date0)-(dob0)/365.25;&lt;/PRE&gt;
&lt;P&gt;Between 1 and 10000 days difference between two dates you will find exactly 6 values that would have an integer result. And that when the formula is:&lt;/P&gt;
&lt;PRE&gt;aget=(date0 - dob0)/365.25;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 14:44:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-sas/m-p/641975#M191450</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-22T14:44:59Z</dc:date>
    </item>
  </channel>
</rss>

