<?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: SAS code explanation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498279#M132373</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp;- the usage of&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;date1 LE any_date LE&lt;/STRONG&gt; last_date is equivalent to say: any_date &lt;STRONG&gt;BETWEEN&lt;/STRONG&gt; date1 and last_date&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184018"&gt;@Geo-&lt;/a&gt;&amp;nbsp;-&amp;nbsp;&lt;/STRONG&gt;I understand that you got some different results using sas vs excel.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the difference in all four variables -&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt; txn_amt_rmb txn_amt_rmb_08 txn_amt_rmb_09 eff_date&lt;/LI-CODE&gt;
&lt;P&gt;are dates equal ?&lt;/P&gt;
&lt;P&gt;while&amp;nbsp;&lt;CODE class="  language-sas"&gt;txn_amt_rmb_08 contains august values,&amp;nbsp;&lt;SPAN&gt;txn_amt_rmb_09 contains september values -&amp;nbsp;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; pay attention that in sas, according to your code,&amp;nbsp;&lt;STRONG&gt;txn_amt_rmb contains values of the whole period.&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt; You have not supplied information what have you done in excel - maybe you summed july only ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to sum each month separately you could do, either:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ccm_base_trans_3m;
	/* retain txn_amt_rmb_08 txn_amt_rmb_09 0; &amp;lt;&amp;lt;&amp;lt; NO NEED */
	set ccm_base_trans(drop=event_id org where=("1jul2014"d le eff_date le "30sep2014"d));
	if "1aug2014"d le eff_date le "31aug2014"d then do;
		txn_amt_rmb_08=txn_amt_rmb;
                txn_amt_rmb = 0;   /* line added */
	end;  ELSE
	if "1sep2014"d le eff_date le "30sep2014"d then do;
		txn_amt_rmb_09=txn_amt_rmb;
                txn_amt_rmb = 0;  /* line added */
		/* txn_date=datepart(eff_date); &amp;lt;&amp;lt;&amp;lt; is eff_date not a date variable ? */
	end;
	length mcc_desc $200.;
	mcc_desc=put(mcc,$mcc.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or you do all in one step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=ccm_base_trans
       (keep=becif_custid txn_amt_rmb txn_amt_rmb_08 txn_amt_rmb_09 eff_date &lt;BR /&gt;         where=("1jul2014"d le eff_date le "30sep2014"d)) nway missing;
	class becif_custid eff_date;
        format eff_date yymms7.;
	var txn_amt_rmb txn  eff_date;
	output out=ccm_base_trans_3m
                  (rename=(_freq_=p3m_sum_cnt) drop=_type_)
		sum(txn_amt_rmb) =p3m_sum_cnt
		max(eff_date)=last_txn_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 24 Sep 2018 05:08:44 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2018-09-24T05:08:44Z</dc:date>
    <item>
      <title>SAS code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498272#M132367</link>
      <description>&lt;P&gt;Hi,someone know summary statement please help me with the&amp;nbsp;explanation&amp;nbsp; of line with number below.&lt;/P&gt;&lt;P&gt;I have written the annotation as I understood my way,however they are not the situation when I check it back in the excel file.&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ccm_base_trans_3m;
	retain txn_amt_rmb_08 txn_amt_rmb_09 0;
	set ccm_base_trans(drop=event_id org where=("1jul2014"d le eff_date le "30sep2014"d));
	if "1aug2014"d le eff_date le "31aug2014"d then do;
		txn_amt_rmb_08=txn_amt_rmb;
	end;
	if "1sep2014"d le eff_date le "30sep2014"d then do;
		txn_amt_rmb_09=txn_amt_rmb;
		txn_date=datepart(eff_date);
	end;
	length mcc_desc $200.;
	mcc_desc=put(mcc,$mcc.);
run;


proc summary data=ccm_base_trans_3m(keep=becif_custid txn_amt_rmb txn_amt_rmb_08 txn_amt_rmb_09 eff_date) nway missing;
/*each becif_custid*/
	class becif_custid;
	var txn_amt_rmb txn_amt_rmb_08 txn_amt_rmb_09 eff_date;
	output out=ccm_base_trans_3m(rename=(_freq_=p3m_sum_cnt) drop=_type_)
/*1.count of txn_amt_rmb for each becif_custid*/
		sum(txn_amt_rmb) =p3m_sum_cnt
/*2.sum of txn_amt_rmb_08  for each becif_custid*/
		sum(txn_amt_rmb_08)=txn_amt_rmb_08
/*3.sum of txn_amt_rmb_09  for each becif_custid*/
		sum(txn_amt_rmb_09)=txn_amt_rmb_09
/*4.last date of eff_date for each becif_custid*/
		max(eff_date)=last_txn_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Sep 2018 02:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498272#M132367</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-09-24T02:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498278#M132372</link>
      <description>&lt;P&gt;&amp;nbsp;Question are you sure that you don't want the beginning of the month to be greater than or equal to rather than less than or equal to?&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token string"&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184018"&gt;@Geo-&lt;/a&gt;has "1jul2014"&lt;/SPAN&gt;&lt;SPAN&gt;d &lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;le&lt;/SPAN&gt;&lt;SPAN&gt; eff_date &lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;le&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"30sep2014"&lt;/SPAN&gt;&lt;SPAN&gt;d&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;would this be the soliton:&amp;nbsp;&lt;SPAN class="token string"&gt;"1jul2014"&lt;/SPAN&gt;d =&amp;gt; eff_date &amp;lt;= &lt;SPAN class="token string"&gt;"30sep2014"&lt;/SPAN&gt;d&amp;nbsp; to change the starting of the test to be within the bounds.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the test&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184018"&gt;@Geo-&lt;/a&gt; has only allows records that meet the condition of less than or equal to the beginning of the month in the first agreement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 03:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498278#M132372</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-09-24T03:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498279#M132373</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp;- the usage of&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;date1 LE any_date LE&lt;/STRONG&gt; last_date is equivalent to say: any_date &lt;STRONG&gt;BETWEEN&lt;/STRONG&gt; date1 and last_date&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184018"&gt;@Geo-&lt;/a&gt;&amp;nbsp;-&amp;nbsp;&lt;/STRONG&gt;I understand that you got some different results using sas vs excel.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the difference in all four variables -&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt; txn_amt_rmb txn_amt_rmb_08 txn_amt_rmb_09 eff_date&lt;/LI-CODE&gt;
&lt;P&gt;are dates equal ?&lt;/P&gt;
&lt;P&gt;while&amp;nbsp;&lt;CODE class="  language-sas"&gt;txn_amt_rmb_08 contains august values,&amp;nbsp;&lt;SPAN&gt;txn_amt_rmb_09 contains september values -&amp;nbsp;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; pay attention that in sas, according to your code,&amp;nbsp;&lt;STRONG&gt;txn_amt_rmb contains values of the whole period.&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt; You have not supplied information what have you done in excel - maybe you summed july only ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to sum each month separately you could do, either:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ccm_base_trans_3m;
	/* retain txn_amt_rmb_08 txn_amt_rmb_09 0; &amp;lt;&amp;lt;&amp;lt; NO NEED */
	set ccm_base_trans(drop=event_id org where=("1jul2014"d le eff_date le "30sep2014"d));
	if "1aug2014"d le eff_date le "31aug2014"d then do;
		txn_amt_rmb_08=txn_amt_rmb;
                txn_amt_rmb = 0;   /* line added */
	end;  ELSE
	if "1sep2014"d le eff_date le "30sep2014"d then do;
		txn_amt_rmb_09=txn_amt_rmb;
                txn_amt_rmb = 0;  /* line added */
		/* txn_date=datepart(eff_date); &amp;lt;&amp;lt;&amp;lt; is eff_date not a date variable ? */
	end;
	length mcc_desc $200.;
	mcc_desc=put(mcc,$mcc.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or you do all in one step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=ccm_base_trans
       (keep=becif_custid txn_amt_rmb txn_amt_rmb_08 txn_amt_rmb_09 eff_date &lt;BR /&gt;         where=("1jul2014"d le eff_date le "30sep2014"d)) nway missing;
	class becif_custid eff_date;
        format eff_date yymms7.;
	var txn_amt_rmb txn  eff_date;
	output out=ccm_base_trans_3m
                  (rename=(_freq_=p3m_sum_cnt) drop=_type_)
		sum(txn_amt_rmb) =p3m_sum_cnt
		max(eff_date)=last_txn_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Sep 2018 05:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498279#M132373</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-09-24T05:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498292#M132382</link>
      <description>thank you for your attention.I could not change thes sas code,I am looking for what the lines with number doing.Did I interpret them right?</description>
      <pubDate>Mon, 24 Sep 2018 07:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498292#M132382</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-09-24T07:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code explanation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498335#M132407</link>
      <description>&lt;P&gt;1 - &lt;STRONG&gt;&lt;SPAN&gt;p3m_sum_cnt&lt;/SPAN&gt;&amp;nbsp;&lt;/STRONG&gt;seems to be erroneous and display either the frequency (count) or the summary of&amp;nbsp;&lt;STRONG&gt;txt_amt_rmb&lt;/STRONG&gt; per customer ID as same variable name was given to both.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2, 3 and 4 - are interpreted correctly;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no summary for the 1st month in the quarter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 09:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-explanation/m-p/498335#M132407</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-09-24T09:45:28Z</dc:date>
    </item>
  </channel>
</rss>

