<?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: &amp;quot;Efficientize&amp;quot; my SQL code in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/quot-Efficientize-quot-my-SQL-code/m-p/66085#M18845</link>
    <description>I think it doesn't like the symbols. Here's the rest:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
le calculated shipdt le  '11JUL2009'd&lt;BR /&gt;
	   and a.no_charge_ind ^= 'Y'&lt;BR /&gt;
	   and a.cancelled_item_status_dt = .&lt;BR /&gt;
	   and a.sales_brand_cd in ('A','W','E','I','P') &lt;BR /&gt;
	   and a.source_mkt ^in ('BRP Cash Management Dev','Cash Management Dev.') &lt;BR /&gt;
	   and calculated promo_method_cd ^in ('G','7','m')&lt;BR /&gt;
&lt;BR /&gt;
	having substr(a.prod_id,1,5) in ('53251' '53252' '53253' '53254' '53151' '53152' '53153' '53154');&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Quit;</description>
    <pubDate>Fri, 21 Aug 2009 17:39:24 GMT</pubDate>
    <dc:creator>sassygrl</dc:creator>
    <dc:date>2009-08-21T17:39:24Z</dc:date>
    <item>
      <title>"Efficientize" my SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-Efficientize-quot-my-SQL-code/m-p/66082#M18842</link>
      <description>Yes, I made up that word &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  I'm just curious if this program could be improved for &lt;I&gt;noticeably&lt;/I&gt; better performance? I'm using a rather archaic machine on rather large data. &lt;BR /&gt;
&lt;BR /&gt;
I apologize in advance if copy/paste doesn't preserve my indenting. Thanks!&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
&lt;BR /&gt;
	/*** All customers who ordered a 3-on intro pack b/t 30Dec2007 and 11Jul2009 ***/&lt;BR /&gt;
	create table outdata.INTROPACKS as&lt;BR /&gt;
	select a.sales_brand_bsnss_id,&lt;BR /&gt;
		   f.current_corp_group_id,&lt;BR /&gt;
		   a.request_id,&lt;BR /&gt;
	       a.request_detail_line_id,&lt;BR /&gt;
	       a.sales_brand_cd,&lt;BR /&gt;
		   b.sales_brand_cd as bbrand_cd,&lt;BR /&gt;
		   a.part_of_kit_cd,&lt;BR /&gt;
		   a.credit_ind,&lt;BR /&gt;
		   a.source_mkt,&lt;BR /&gt;
		   a.software_cd,&lt;BR /&gt;
		   a.booked_amt,&lt;BR /&gt;
		   a.order_discount_amt,&lt;BR /&gt;
		   a.discount_amt,&lt;BR /&gt;
		   a.rev,&lt;BR /&gt;
		   datepart(a.shipped_item_status_dt) as shipdt format date9.,&lt;BR /&gt;
		   datepart(a.shipped_item_status_dt)+30 as shipplus30 format date9.,&lt;BR /&gt;
		   datepart(a.shipped_item_status_dt)+60 as shipplus60 format date9.,&lt;BR /&gt;
		   datepart(a.shipped_item_status_dt)+90 as shipplus90 format date9.,&lt;BR /&gt;
		   datepart(a.billed_item_status_dt) as billdt format date9.,&lt;BR /&gt;
	       a.prod_id,&lt;BR /&gt;
		   c.prod_line_cd,&lt;BR /&gt;
		   d.prod_line_cd_desc,&lt;BR /&gt;
	       case when b.promo_method_cd^='' then b.promo_method_cd &lt;BR /&gt;
				when b.promo_method_cd='' and b.sales_brand_bsnss_id^='' then 'm'&lt;BR /&gt;
				else '' &lt;BR /&gt;
				end as promo_method_cd,&lt;BR /&gt;
		   e.promo_method_cd_desc&lt;BR /&gt;
&lt;BR /&gt;
	from  SASWORK.weekly_line_item_wk28  a   &lt;BR /&gt;
&lt;BR /&gt;
		   left join SASOWNER.SBS_REQUEST_T   b&lt;BR /&gt;
				on (a.sales_brand_cd=b.sales_brand_cd &lt;BR /&gt;
						or (a.sales_brand_cd in ('A','W') and b.sales_brand_cd in ('A','W')))       &lt;BR /&gt;
					and a.request_id           = b.request_id 	      &lt;BR /&gt;
				 /* and a.sales_brand_bsnss_id = b.sales_brand_bsnss_id */&lt;BR /&gt;
&lt;BR /&gt;
		   left join (select distinct prod_id, prod_line_cd&lt;BR /&gt;
					  from SASOWNER.SBS_PROD_ID_T)  c&lt;BR /&gt;
				on a.prod_id = c.prod_id&lt;BR /&gt;
&lt;BR /&gt;
		   left join SASOWNER.SBS_PROD_LINE_T  d&lt;BR /&gt;
				on c.prod_line_cd = d.prod_line_cd&lt;BR /&gt;
&lt;BR /&gt;
		   left join SASOWNER.SBS_REF_PROMO_METHOD_CD_T  e&lt;BR /&gt;
		   		on b.promo_method_cd = e.promo_method_cd&lt;BR /&gt;
&lt;BR /&gt;
		   left join SASOWNER.SBS_PERKEY_XREF_T  f&lt;BR /&gt;
		   		on a.sales_brand_bsnss_id = f.sales_brand_bsnss_id&lt;BR /&gt;
&lt;BR /&gt;
	where '30DEC2007'd &amp;lt;= calculated shipdt &amp;lt;=  '11JUL2009'd&lt;BR /&gt;
	   /*and a.part_of_kit_cd ^= 'C'*/&lt;BR /&gt;
	   and a.no_charge_ind ^= 'Y'&lt;BR /&gt;
	   and a.cancelled_item_status_dt = .&lt;BR /&gt;
	   and a.sales_brand_cd in ('A','W','E','I','P') &lt;BR /&gt;
	   and a.source_mkt ^in ('BRP Cash Management Dev','Cash Management Dev.') &lt;BR /&gt;
	   and calculated promo_method_cd ^in ('G','7','m')&lt;BR /&gt;
&lt;BR /&gt;
	having substr(a.prod_id,1,5) in ('53251' '53252' '53253' '53254' '53151' '53152' '53153' '53154');&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
	/*** Unique list of SBBID who ordered intro pack ***/&lt;BR /&gt;
	create table LIST as&lt;BR /&gt;
	select distinct sales_brand_bsnss_id, current_corp_group_id&lt;BR /&gt;
	from outdata.INTROPACKS;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
	/*** Above customers who also ordered a laser check product ***/&lt;BR /&gt;
	create table outdata.LASERCHECKS as&lt;BR /&gt;
	select z.sales_brand_bsnss_id,&lt;BR /&gt;
		   z.current_corp_group_id,&lt;BR /&gt;
		   a.request_id,&lt;BR /&gt;
	       a.request_detail_line_id,&lt;BR /&gt;
	       a.sales_brand_cd,&lt;BR /&gt;
		   b.sales_brand_cd as bbrand_cd,&lt;BR /&gt;
		   a.part_of_kit_cd,&lt;BR /&gt;
		   a.credit_ind,&lt;BR /&gt;
		   a.source_mkt,&lt;BR /&gt;
		   a.software_cd,&lt;BR /&gt;
		   a.booked_amt,&lt;BR /&gt;
		   a.order_discount_amt,&lt;BR /&gt;
		   a.discount_amt,&lt;BR /&gt;
		   a.rev,&lt;BR /&gt;
		   datepart(a.shipped_item_status_dt) as shipdt format date9.,&lt;BR /&gt;
		   datepart(a.billed_item_status_dt) as billdt format date9.,&lt;BR /&gt;
	       a.prod_id,&lt;BR /&gt;
		   c.prod_line_cd,&lt;BR /&gt;
		   d.prod_line_cd_desc,&lt;BR /&gt;
	       case when b.promo_method_cd^='' then b.promo_method_cd &lt;BR /&gt;
				when b.promo_method_cd='' and b.sales_brand_bsnss_id^='' then 'm'&lt;BR /&gt;
				else '' &lt;BR /&gt;
				end as promo_method_cd,&lt;BR /&gt;
		   e.promo_method_cd_desc&lt;BR /&gt;
&lt;BR /&gt;
	from  LIST z left join SASWORK.weekly_line_item_wk28  a&lt;BR /&gt;
			 	on z.sales_brand_bsnss_id = a.sales_brand_bsnss_id&lt;BR /&gt;
	&lt;BR /&gt;
		   left join SASOWNER.SBS_REQUEST_T   b&lt;BR /&gt;
				on (a.sales_brand_cd=b.sales_brand_cd &lt;BR /&gt;
						or (a.sales_brand_cd in ('A','W') and b.sales_brand_cd in ('A','W')))       &lt;BR /&gt;
					and a.request_id           = b.request_id 	      &lt;BR /&gt;
				 /* and a.sales_brand_bsnss_id = b.sales_brand_bsnss_id */&lt;BR /&gt;
&lt;BR /&gt;
		   left join (select distinct prod_id, prod_line_cd&lt;BR /&gt;
					  from SASOWNER.SBS_PROD_ID_T)  c&lt;BR /&gt;
				on a.prod_id = c.prod_id&lt;BR /&gt;
&lt;BR /&gt;
		   left join SASOWNER.SBS_PROD_LINE_T  d&lt;BR /&gt;
				on c.prod_line_cd = d.prod_line_cd&lt;BR /&gt;
&lt;BR /&gt;
		   left join SASOWNER.SBS_REF_PROMO_METHOD_CD_T  e&lt;BR /&gt;
		   		on b.promo_method_cd = e.promo_method_cd&lt;BR /&gt;
&lt;BR /&gt;
	 where '30DEC2007'd &amp;lt;= calculated billdt &amp;lt;= '11JUL2009'd&lt;BR /&gt;
	   /*and a.part_of_kit_cd ^= 'C'*/&lt;BR /&gt;
	   and a.no_charge_ind ^= 'Y'&lt;BR /&gt;
	   and a.cancelled_item_status_dt = .&lt;BR /&gt;
	   and c.prod_line_cd = '10'&lt;BR /&gt;
	   and a.sales_brand_cd in ('A','W','E','I','P')  &lt;BR /&gt;
	   and a.source_mkt ^in ('BRP Cash Management Dev','Cash Management Dev.') &lt;BR /&gt;
	   and calculated promo_method_cd ^in ('G','7','m');&lt;BR /&gt;
&lt;BR /&gt;
 quit;</description>
      <pubDate>Fri, 21 Aug 2009 17:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-Efficientize-quot-my-SQL-code/m-p/66082#M18842</guid>
      <dc:creator>sassygrl</dc:creator>
      <dc:date>2009-08-21T17:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: "Efficientize" my SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-Efficientize-quot-my-SQL-code/m-p/66083#M18843</link>
      <description>&amp;lt;= calculated shipdt &amp;lt;=  '11JUL2009'd&lt;BR /&gt;
	   /*and a.part_of_kit_cd ^= 'C'*/&lt;BR /&gt;
	   and a.no_charge_ind ^= 'Y'&lt;BR /&gt;
	   and a.cancelled_item_status_dt = .&lt;BR /&gt;
	   and a.sales_brand_cd in ('A','W','E','I','P') &lt;BR /&gt;
	   and a.source_mkt ^in ('BRP Cash Management Dev','Cash Management Dev.') &lt;BR /&gt;
	   and calculated promo_method_cd ^in ('G','7','m')&lt;BR /&gt;
&lt;BR /&gt;
	having substr(a.prod_id,1,5) in ('53251' '53252' '53253' '53254' '53151' '53152' '53153' '53154');&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
	/*** Unique list of SBBID who ordered intro pack ***/&lt;BR /&gt;
	create table LIST as&lt;BR /&gt;
	select distinct sales_brand_bsnss_id, current_corp_group_id&lt;BR /&gt;
	from outdata.INTROPACKS;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
	/*** Above customers who also ordered a laser check product ***/&lt;BR /&gt;
	create table outdata.LASERCHECKS as&lt;BR /&gt;
	select z.sales_brand_bsnss_id,&lt;BR /&gt;
		   z.current_corp_group_id,&lt;BR /&gt;
		   a.request_id,&lt;BR /&gt;
	       a.request_detail_line_id,&lt;BR /&gt;
	       a.sales_brand_cd,&lt;BR /&gt;
		   b.sales_brand_cd as bbrand_cd,&lt;BR /&gt;
		   a.part_of_kit_cd,&lt;BR /&gt;
		   a.credit_ind,&lt;BR /&gt;
		   a.source_mkt,&lt;BR /&gt;
		   a.software_cd,&lt;BR /&gt;
		   a.booked_amt,&lt;BR /&gt;
		   a.order_discount_amt,&lt;BR /&gt;
		   a.discount_amt,&lt;BR /&gt;
		   a.rev,&lt;BR /&gt;
		   datepart(a.shipped_item_status_dt) as shipdt format date9.,&lt;BR /&gt;
		   datepart(a.billed_item_status_dt) as billdt format date9.,&lt;BR /&gt;
	       a.prod_id,&lt;BR /&gt;
		   c.prod_line_cd,&lt;BR /&gt;
		   d.prod_line_cd_desc,&lt;BR /&gt;
	       case when b.promo_method_cd^='' then b.promo_method_cd &lt;BR /&gt;
				when b.promo_method_cd='' and b.sales_brand_bsnss_id^='' then 'm'&lt;BR /&gt;
				else '' &lt;BR /&gt;
				end as promo_method_cd,&lt;BR /&gt;
		   e.promo_method_cd_desc&lt;BR /&gt;
&lt;BR /&gt;
	from  LIST z left join SASWORK.weekly_line_item_wk28  a&lt;BR /&gt;
			 	on z.sales_brand_bsnss_id = a.sales_brand_bsnss_id&lt;BR /&gt;
	&lt;BR /&gt;
		   left join SASOWNER.SBS_REQUEST_T   b&lt;BR /&gt;
				on (a.sales_brand_cd=b.sales_brand_cd &lt;BR /&gt;
						or (a.sales_brand_cd in ('A','W') and b.sales_brand_cd in ('A','W')))       &lt;BR /&gt;
					and a.request_id           = b.request_id 	      &lt;BR /&gt;
				 /* and a.sales_brand_bsnss_id = b.sales_brand_bsnss_id */&lt;BR /&gt;
&lt;BR /&gt;
		   left join (select distinct prod_id, prod_line_cd&lt;BR /&gt;
					  from SASOWNER.SBS_PROD_ID_T)  c&lt;BR /&gt;
				on a.prod_id = c.prod_id&lt;BR /&gt;
&lt;BR /&gt;
		   left join SASOWNER.SBS_PROD_LINE_T  d&lt;BR /&gt;
				on c.prod_line_cd = d.prod_line_cd&lt;BR /&gt;
&lt;BR /&gt;
		   left join SASOWNER.SBS_REF_PROMO_METHOD_CD_T  e&lt;BR /&gt;
		   		on b.promo_method_cd = e.promo_method_cd&lt;BR /&gt;
&lt;BR /&gt;
	 where '30DEC2007'd &amp;lt;= calculated billdt &amp;lt;= '11JUL2009'd&lt;BR /&gt;
	   /*and a.part_of_kit_cd ^= 'C'*/&lt;BR /&gt;
	   and a.no_charge_ind ^= 'Y'&lt;BR /&gt;
	   and a.cancelled_item_status_dt = .&lt;BR /&gt;
	   and c.prod_line_cd = '10'&lt;BR /&gt;
	   and a.sales_brand_cd in ('A','W','E','I','P')  &lt;BR /&gt;
	   and a.source_mkt ^in ('BRP Cash Management Dev','Cash Management Dev.') &lt;BR /&gt;
	   and calculated promo_method_cd ^in ('G','7','m');&lt;BR /&gt;
&lt;BR /&gt;
 quit;

Message was edited by: sassygrl</description>
      <pubDate>Fri, 21 Aug 2009 17:34:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-Efficientize-quot-my-SQL-code/m-p/66083#M18843</guid>
      <dc:creator>sassygrl</dc:creator>
      <dc:date>2009-08-21T17:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: "Efficientize" my SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-Efficientize-quot-my-SQL-code/m-p/66084#M18844</link>
      <description>My apologies, it is not allowing me to post any more of my code &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Fri, 21 Aug 2009 17:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-Efficientize-quot-my-SQL-code/m-p/66084#M18844</guid>
      <dc:creator>sassygrl</dc:creator>
      <dc:date>2009-08-21T17:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: "Efficientize" my SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/quot-Efficientize-quot-my-SQL-code/m-p/66085#M18845</link>
      <description>I think it doesn't like the symbols. Here's the rest:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
le calculated shipdt le  '11JUL2009'd&lt;BR /&gt;
	   and a.no_charge_ind ^= 'Y'&lt;BR /&gt;
	   and a.cancelled_item_status_dt = .&lt;BR /&gt;
	   and a.sales_brand_cd in ('A','W','E','I','P') &lt;BR /&gt;
	   and a.source_mkt ^in ('BRP Cash Management Dev','Cash Management Dev.') &lt;BR /&gt;
	   and calculated promo_method_cd ^in ('G','7','m')&lt;BR /&gt;
&lt;BR /&gt;
	having substr(a.prod_id,1,5) in ('53251' '53252' '53253' '53254' '53151' '53152' '53153' '53154');&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Quit;</description>
      <pubDate>Fri, 21 Aug 2009 17:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/quot-Efficientize-quot-my-SQL-code/m-p/66085#M18845</guid>
      <dc:creator>sassygrl</dc:creator>
      <dc:date>2009-08-21T17:39:24Z</dc:date>
    </item>
  </channel>
</rss>

