<?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 TIme in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315195#M68702</link>
    <description>&lt;P&gt;Please delete this thread.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Dec 2016 10:09:24 GMT</pubDate>
    <dc:creator>Boa</dc:creator>
    <dc:date>2016-12-05T10:09:24Z</dc:date>
    <item>
      <title>TIme</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315195#M68702</link>
      <description>&lt;P&gt;Please delete this thread.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 10:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315195#M68702</guid>
      <dc:creator>Boa</dc:creator>
      <dc:date>2016-12-05T10:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in Date function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315202#M68703</link>
      <description>&lt;P&gt;Sorry, your question really isn't clear. &amp;nbsp;What do you mean by "filter out", do you want to create datasets with these conditions?&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  mnth=month(datepart(orderdate));
run;
proc sort data=want out=want_month nodupkey;
  by mnth;
run;&lt;/PRE&gt;
&lt;P&gt;And sum up:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT_SUM as
  select  year(datepart(ORDERDATE)) as YR,
              month(datepart(ORDERDATE)) as MNTH,
              sum(TOTALAMOUNT) as TOT
  from    HAVE
  group by year(datepart(ORDERDATE)),
              month(datepart(ORDERDATE));
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Nov 2016 15:04:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315202#M68703</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-29T15:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in Date function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315205#M68705</link>
      <description />
      <pubDate>Mon, 05 Dec 2016 10:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315205#M68705</guid>
      <dc:creator>Boa</dc:creator>
      <dc:date>2016-12-05T10:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in Date function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315206#M68706</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select
  year(datepart(orderdate)) as year,
  month(datepart(orderdate)) as month,
  sum(totalamount) as sales
from have
group by calculated year, calculated month
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Nov 2016 15:10:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315206#M68706</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-29T15:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in Date function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315207#M68707</link>
      <description>&lt;P&gt;First a comment on data sources that force datetime values when there is no actual time component: find out who is doing this and teach them some manners.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One approach would be a custom format as SAS does not supply a Monname or equivalent format for datetime values.&lt;/P&gt;
&lt;P&gt;Filtering for year is likely easiest by using:&lt;/P&gt;
&lt;P&gt;where year(datepart(orderdate)) = 2008 if the value is datetime or&lt;/P&gt;
&lt;P&gt;where year(orderdate)-2008&amp;nbsp; if the value is a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If &lt;STRONG&gt;your&lt;/STRONG&gt; process never needs the time component it may be easier to just change the variable type:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; orderdate = datepart(orderdate);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;will make order date an actual date value. Then you can could use a format in report procedures to group by month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data= have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where year(orderdate)=2008;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; class orderdate;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format orderdate MONNAME3. ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var totalamount;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; table orderdate,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; totalamount*sum='';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 15:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315207#M68707</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-29T15:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in Date function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315208#M68708</link>
      <description>&lt;P&gt;Then my second code should work fine, although I second&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser﻿&lt;/a&gt;&amp;nbsp;in that using the calculated values would make the code smaller. &amp;nbsp; &amp;nbsp;Also, Data is the plural, there is no such thing as "datas" &lt;span class="lia-unicode-emoji" title=":monkey_face:"&gt;🐵&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 15:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315208#M68708</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-29T15:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in Date function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315226#M68714</link>
      <description />
      <pubDate>Mon, 05 Dec 2016 10:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315226#M68714</guid>
      <dc:creator>Boa</dc:creator>
      <dc:date>2016-12-05T10:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in Date function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315235#M68718</link>
      <description>&lt;P&gt;Add a suitable where condition in my proc sql code.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 16:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315235#M68718</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-29T16:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in Date function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315253#M68724</link>
      <description>&lt;P&gt;Sub-query the data first:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT_SUM as
  select  YR,
          MNTH,
          sum(TOTALAMOUNT) as TOT
  from    (select year(datepart(ORDERDATE)) as YR,&lt;BR /&gt;                  month(datepart(ORDERDATE)) as MNTH,&lt;BR /&gt;                  TOTALAMOUNT&lt;BR /&gt;           from   HAVE&lt;BR /&gt;           where calculated YR=2008)
  group by YR,MNTH;
quit;&lt;/PRE&gt;
&lt;P&gt;You could also do it using a "having" clause, though I prefer the sub-query. &amp;nbsp;You can also do it in datastep:&lt;/P&gt;
&lt;PRE&gt;data inter;
  set have (where=(year(datepart(orderdate))=2008);
  yr=2008;
  mnth=month(datepart(orderdate));
run;

data want;
  set inter;
  by mnth;
  retain tot;
  tot=ifn(first.mnth,0,tot+totalamount);&lt;BR /&gt;run; &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 16:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TIme/m-p/315253#M68724</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-29T16:55:38Z</dc:date>
    </item>
  </channel>
</rss>

