<?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 current age in proc report in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549011#M74456</link>
    <description>&lt;P&gt;You would be better off calculating age and adding as a column to your data before using PROC REPORT. There are many posts on this topic in the SAS Community. Try searching for them. This is one example:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Calculate-Age-from-Birth-Date/m-p/434973#M107998" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Calculate-Age-from-Birth-Date/m-p/434973#M107998&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Apr 2019 03:43:37 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2019-04-06T03:43:37Z</dc:date>
    <item>
      <title>Calculate current age in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549006#M74454</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code. I am unable to calculate today and days. It's not printing anything. &lt;SPAN&gt;What format do i need to use ?&lt;/SPAN&gt;&lt;BR /&gt;proc report data=profile (where=(state in('NY' , 'CA')));&lt;BR /&gt;column Acct_ID Name today days Birthday Age Sex State Cust_Type Product Balance Last_Tran_Date;&lt;BR /&gt;define state / order;&lt;BR /&gt;define Acct_ID / order width=6;&lt;BR /&gt;define Name / order "Name" width=5;&lt;BR /&gt;define today /computed format= date9. ;&lt;BR /&gt;define days / computed format=mmddyy10. ;&lt;BR /&gt;define Birthday / order format=mmddyy10. ;&lt;BR /&gt;define Sex / order noprint;&lt;BR /&gt;define Cust_Type / order noprint;&lt;BR /&gt;define Product / order noprint;&lt;BR /&gt;define Age / computed format= mmddyy10.;&lt;BR /&gt;Define Balance / order width=5;&lt;BR /&gt;define Last_Tran_Date / order format=mmddyy10.;&lt;BR /&gt;compute after today;&lt;BR /&gt;today = date(),anydtdte.;&lt;BR /&gt;endcomp;&lt;BR /&gt;compute before days;&lt;BR /&gt;days = today - Birthday;&lt;BR /&gt;endcomp;&lt;BR /&gt;compute before Age;&lt;BR /&gt;Age = floor(days / 365);&lt;BR /&gt;endcomp;&lt;BR /&gt;/*BREAK AFTER Balance / SUMMARIZE;*/&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2019 02:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549006#M74454</guid>
      <dc:creator>oraha</dc:creator>
      <dc:date>2019-04-06T02:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549011#M74456</link>
      <description>&lt;P&gt;You would be better off calculating age and adding as a column to your data before using PROC REPORT. There are many posts on this topic in the SAS Community. Try searching for them. This is one example:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Calculate-Age-from-Birth-Date/m-p/434973#M107998" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Calculate-Age-from-Birth-Date/m-p/434973#M107998&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2019 03:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549011#M74456</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-04-06T03:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549014#M74457</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;This is my code. I am unable to calculate today and days. It's not printing anything&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Does your log have errors? Is it calculating anything? Can you provide sample data?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here are instructions on how to provide sample data&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266782"&gt;@oraha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my code. I am unable to calculate today and days. It's not printing anything. &lt;SPAN&gt;What format do i need to use ?&lt;/SPAN&gt;&lt;BR /&gt;proc report data=profile (where=(state in('NY' , 'CA')));&lt;BR /&gt;column Acct_ID Name today days Birthday Age Sex State Cust_Type Product Balance Last_Tran_Date;&lt;BR /&gt;define state / order;&lt;BR /&gt;define Acct_ID / order width=6;&lt;BR /&gt;define Name / order "Name" width=5;&lt;BR /&gt;define today /computed format= date9. ;&lt;BR /&gt;define days / computed format=mmddyy10. ;&lt;BR /&gt;define Birthday / order format=mmddyy10. ;&lt;BR /&gt;define Sex / order noprint;&lt;BR /&gt;define Cust_Type / order noprint;&lt;BR /&gt;define Product / order noprint;&lt;BR /&gt;define Age / computed format= mmddyy10.;&lt;BR /&gt;Define Balance / order width=5;&lt;BR /&gt;define Last_Tran_Date / order format=mmddyy10.;&lt;BR /&gt;compute after today;&lt;BR /&gt;today = date(),anydtdte.;&lt;BR /&gt;endcomp;&lt;BR /&gt;compute before days;&lt;BR /&gt;days = today - Birthday;&lt;BR /&gt;endcomp;&lt;BR /&gt;compute before Age;&lt;BR /&gt;Age = floor(days / 365);&lt;BR /&gt;endcomp;&lt;BR /&gt;/*BREAK AFTER Balance / SUMMARIZE;*/&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2019 04:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549014#M74457</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-06T04:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549043#M74461</link>
      <description>&lt;P&gt;Its's not calculating anything, just empty columns for today and days. It's not giving error.&lt;/P&gt;&lt;P&gt;Sample data:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Acct_ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Name&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Birthday&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Sex&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;State&lt;/P&gt;&lt;/TD&g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gt;&lt;TD&gt;&lt;P&gt;Gold&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Saving&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;5000&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1006&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Susan&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6/1/1997&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;F&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;WA&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Gold&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Loan&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1000&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;9/15/2016&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sat, 06 Apr 2019 14:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549043#M74461</guid>
      <dc:creator>oraha</dc:creator>
      <dc:date>2019-04-06T14:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549068#M74462</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;I'm not in a position to run any code now, but you should search the Forums for previous tracks about the PROC REPORT "left-to-right" rule.&lt;BR /&gt;&lt;BR /&gt;But first, you have some basic PROC REPORT errors. I would imagine that you are getting errors in the log for your COMPUTE AFTER TODAY or COMPUTE BEFORE DAYS that you can only do break processing on GROUP or ORDER items. But TODAY, AGE and DAYS are all COMPUTED, so BREAK processing such as COMPUTE BEFORE/AFTER will NOT work.&lt;BR /&gt;&lt;BR /&gt;Next, your code is violating the "left-to-right" rule which is that if I have a COLUMN statement like this:&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;COLUMN var1 var2 var3 var3 var5;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Then when PROC REPORT is putting &lt;FONT face="courier new,courier"&gt;VAR1&lt;/FONT&gt; on the report row, it has no visibility of the values for &lt;FONT face="courier new,courier"&gt;VAR2, VAR3, VAR4&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;VAR5&lt;/FONT&gt;.&lt;BR /&gt;&lt;BR /&gt;When&lt;FONT face="courier new,courier"&gt; VAR1&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;VAR2&lt;/FONT&gt; have been placed on the report row, there is still no visibility of &lt;FONT face="courier new,courier"&gt;VAR3, VAR4&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;VAR5&lt;/FONT&gt;. At this point in timing, a COMPUTE block for &lt;FONT face="courier new,courier"&gt;VAR2&lt;/FONT&gt; can refer to &lt;FONT face="courier new,courier"&gt;VAR1&lt;/FONT&gt;; however, a COMPUTE block for &lt;FONT face="courier new,courier"&gt;VAR1&lt;/FONT&gt; &lt;U&gt;&lt;STRONG&gt;CANNOT&lt;/STRONG&gt; &lt;/U&gt;refer to &lt;FONT face="courier new,courier"&gt;VAR2&lt;/FONT&gt;.&lt;BR /&gt;&lt;BR /&gt;Processing continues the same way. At the point in time when &lt;FONT face="courier new,courier"&gt;VAR4&lt;/FONT&gt; is placed on the report row, a COMPUTE block for &lt;FONT face="courier new,courier"&gt;VAR4&lt;/FONT&gt; could reference &lt;FONT face="courier new,courier"&gt;VAR1, VAR2&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;VAR3&lt;/FONT&gt;, but could NOT reference &lt;FONT face="courier new,courier"&gt;VAR5&lt;/FONT&gt;.&lt;BR /&gt;&lt;BR /&gt;There have been many different forum postings about the left-to-right rule. But even so, you've got to fix your other problems first.&lt;BR /&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2019 22:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549068#M74462</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-04-06T22:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549101#M74470</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have to follow left to right rule of proc report before computing any new variable. Here is an example as per your data..&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this will help to resolve your problem..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=profil;
column Acct_ID Name  Birthday today days age;
define acct_id/order;
define name /display;
define birthday/display;
define today/computed format=date9.;
compute today;
 today=today();
endcomp;
compute days;
days= _c4_ - _c3_;
endcomp;
compute age;
age=floor(_c5_/365);
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2019 05:33:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age-in-proc-report/m-p/549101#M74470</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2019-04-07T05:33:39Z</dc:date>
    </item>
  </channel>
</rss>

