<?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: proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510755#M137455</link>
    <description>&lt;P&gt;Start by giving us a picture of your data. Post some example data in a data step with datalines, so we can quickly and accurately recreate your dataset and play around with it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to give you an idea how to solve it with a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let ref_date=%sysfunc(today());

data have;
input call_date :yymmdd10. no_of_calls;
datalines;
2018-01-01 1
2018-08-09 4
2018-10-03 2
2018-11-01 3
;
run;

data want (keep=sum_month sum_prev_month sum_trim sum_year);
set have end=eof;
retain
  sum_month 0
  sum_prev_month 0
  sum_trim 0
  sum_year 0
;
if intck('month',call_date,&amp;amp;ref_date.,'c') &amp;lt; 1 then sum_month + no_of_calls;
if 1 &amp;lt;= intck('month',call_date,&amp;amp;ref_date.,'c') &amp;lt; 2 then sum_prev_month + no_of_calls;
if intck('month',call_date,&amp;amp;ref_date.,'c') &amp;lt;= 4 then sum_trim + no_of_calls;
if intck('month',call_date,&amp;amp;ref_date.,'c') &amp;lt;= 12 then sum_year + no_of_calls;
if eof then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Nov 2018 14:15:23 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-11-06T14:15:23Z</dc:date>
    <item>
      <title>proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510744#M137451</link>
      <description>&lt;P&gt;Hello Everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help for a report I'm doing on SAS 9.4 , I have to sum the number of customer calls depending on a date, let's say 31/01/2018 :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need in seperate columns : The month sum, the last month sum, the last trimester sum and the last 12 months sum .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really dont know how to do it , here a screenshot of the data :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24724i02D4834A8606F712/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any tips, I put on attach how this need to look&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CaptureSAS.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24708iBDA4849D393DC8B6/image-size/large?v=v2&amp;amp;px=999" role="button" title="CaptureSAS.PNG" alt="CaptureSAS.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 09:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510744#M137451</guid>
      <dc:creator>yankee241</dc:creator>
      <dc:date>2018-11-07T09:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510749#M137452</link>
      <description>&lt;P&gt;Welcome to the SAS forum &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will have much better luck in finding a usable code answer if you provide us with some data that represents your actual data alog with a description of your desired result.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 13:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510749#M137452</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-11-06T13:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510751#M137453</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CaptureSAS.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24707iE0804137B133814F/image-size/large?v=v2&amp;amp;px=999" role="button" title="CaptureSAS.PNG" alt="CaptureSAS.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The variable changing in the stored process will be the date, depending on the day they choose, I need to provide the first column with the blue title as the sum of the 1st of the month and the date (if it's 15/01/2018 , then it will be the 1st to the 15th) , the last month (december in this case) , the last 3 month and the last 12 month )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all depending on the site (region) and the job (PFS, Prod.... )&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 14:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510751#M137453</guid>
      <dc:creator>yankee241</dc:creator>
      <dc:date>2018-11-06T14:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510755#M137455</link>
      <description>&lt;P&gt;Start by giving us a picture of your data. Post some example data in a data step with datalines, so we can quickly and accurately recreate your dataset and play around with it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to give you an idea how to solve it with a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let ref_date=%sysfunc(today());

data have;
input call_date :yymmdd10. no_of_calls;
datalines;
2018-01-01 1
2018-08-09 4
2018-10-03 2
2018-11-01 3
;
run;

data want (keep=sum_month sum_prev_month sum_trim sum_year);
set have end=eof;
retain
  sum_month 0
  sum_prev_month 0
  sum_trim 0
  sum_year 0
;
if intck('month',call_date,&amp;amp;ref_date.,'c') &amp;lt; 1 then sum_month + no_of_calls;
if 1 &amp;lt;= intck('month',call_date,&amp;amp;ref_date.,'c') &amp;lt; 2 then sum_prev_month + no_of_calls;
if intck('month',call_date,&amp;amp;ref_date.,'c') &amp;lt;= 4 then sum_trim + no_of_calls;
if intck('month',call_date,&amp;amp;ref_date.,'c') &amp;lt;= 12 then sum_year + no_of_calls;
if eof then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 14:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510755#M137455</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-06T14:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510759#M137457</link>
      <description>&lt;P&gt;Thank you for the tip, I will edit my first message once I have my data available; I'm not at work today.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 14:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/510759#M137457</guid>
      <dc:creator>yankee241</dc:creator>
      <dc:date>2018-11-06T14:31:16Z</dc:date>
    </item>
  </channel>
</rss>

