<?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: How to get product count which are new to customers? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498132#M132284</link>
    <description>&lt;P&gt;When I try it, it gives me the observations which took place after 2016. Irrespective of it being repeated in the previous year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to exclude products ordered by a customers more than once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say for example&lt;/P&gt;&lt;P&gt;in the attached excel sheet there are 10 products(highlighted in yellow) new to the customer(not ordered in their previous encounters). I want&amp;nbsp; those rows to be shown in the results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 22 Sep 2018 23:26:06 GMT</pubDate>
    <dc:creator>ihtishamsultan</dc:creator>
    <dc:date>2018-09-22T23:26:06Z</dc:date>
    <item>
      <title>How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498016#M132209</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a newbie trying to learn and had a query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to identify new products being ordered by&amp;nbsp; customers.&amp;nbsp; I want to check if a customer has placed a order(say in 2016 and 2017) ,did he/she order the same product in 2014-2015 or is it something new to him/her.&amp;nbsp; If it is new then I want to have the count of new ordered products(how many products new to the customer were ordered), the count of customers ordering new product and sales man id associated with order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Every item purchased has a unique ID Prod_id, Customer is represented by Customer_id, date of order is Order_date and sales man is represented by sales_id.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help will be highly appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 01:10:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498016#M132209</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2018-09-22T01:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498017#M132210</link>
      <description>&lt;P&gt;Help us help you.&amp;nbsp; Show what the incoming data looks like. Show what you want the result data&amp;nbsp; to look like.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 01:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498017#M132210</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-09-22T01:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498018#M132211</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;incoming data is sales data for a store from 2014-2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cust_id, order_date and sales id are character variables. Prod_id is numeric variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the results&amp;nbsp;in a tabular form and to only include products that were new to customer(not ordered in the previous two years)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cust_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; prod_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sales_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;order_date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A345&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;74&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; S231&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/09/2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sorry, I am new to all this, is this what was expected ??&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 01:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498018#M132211</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2018-09-22T01:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498022#M132214</link>
      <description>&lt;P&gt;you could do this using Proc SQL and a union statement for customer Id and product.&lt;/P&gt;&lt;P&gt;if you would like a sample please post sample data that represents your case with more than one sample.&amp;nbsp; While we can create a lot of sample data using your example is best because the solutions will fit your case study.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 01:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498022#M132214</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-09-22T01:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498029#M132218</link>
      <description>&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Salesman_name&lt;/TD&gt;&lt;TD&gt;Prod_id&lt;/TD&gt;&lt;TD&gt;Order_date&lt;/TD&gt;&lt;TD&gt;Cust_name&lt;/TD&gt;&lt;TD&gt;Sales_id&lt;/TD&gt;&lt;TD&gt;Cust_id&lt;/TD&gt;&lt;TD&gt;Paymode_ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;john&lt;/TD&gt;&lt;TD&gt;233&lt;/TD&gt;&lt;TD&gt;3/27/2017&lt;/TD&gt;&lt;TD&gt;Bill.N&lt;/TD&gt;&lt;TD&gt;S1922&lt;/TD&gt;&lt;TD&gt;J231&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;john&lt;/TD&gt;&lt;TD&gt;235&lt;/TD&gt;&lt;TD&gt;3/27/2017&lt;/TD&gt;&lt;TD&gt;Bill.N&lt;/TD&gt;&lt;TD&gt;S1922&lt;/TD&gt;&lt;TD&gt;J231&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;john&lt;/TD&gt;&lt;TD&gt;244&lt;/TD&gt;&lt;TD&gt;3/27/2017&lt;/TD&gt;&lt;TD&gt;Bill.N&lt;/TD&gt;&lt;TD&gt;S1922&lt;/TD&gt;&lt;TD&gt;J231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;TD&gt;603&lt;/TD&gt;&lt;TD&gt;3/29/2017&lt;/TD&gt;&lt;TD&gt;Rana&lt;/TD&gt;&lt;TD&gt;S1872&lt;/TD&gt;&lt;TD&gt;R189&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Couldn't copy the whole things, the data set has 53 variables and around 300,000 rows for 4 years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 02:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498029#M132218</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2018-09-22T02:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498032#M132221</link>
      <description>&lt;P&gt;You did not supply data that would meet the selection criteria you have listed.&lt;/P&gt;&lt;P&gt;I created extra records to confirm this works.&amp;nbsp; But you will need to create the order_year our of the order_date for the logic to work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table want as
	select a.*, b.order_date as prior_order_date
	from have2 as a, have2 as b
	where a.salesman_name = b.salesman_name 
		  and a.prod_id = b.prod_id 
		  and b.order_year in (2014,2015) 
		  and a.order_year in (2016,2017);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note this in not using a union but works for your case study.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 03:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498032#M132221</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-09-22T03:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498035#M132223</link>
      <description>&lt;P&gt;If the data are sorted by date,&amp;nbsp; or by date within cust_id then this works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  if _n_=1 then do;
    declare hash h ();
      h.definekey('cust_id','prod_id');
      h.definedone();
  end;
  set have;
  if date&amp;lt;'01jan2016'd then h.add();
  if date&amp;gt;='01jan2016'd and h.find()^=0;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;At the first incoming observation, this program instantiates a hash object (a "lookup table" in this case) keyed on cust_id/prod_id.&amp;nbsp; The object only is populated (one record at a time) by instances in which date &amp;lt; '01jan2016'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then when later dates are encountered, the h.find method looks to see if the incoming cust_id/prod_id is already in the object (indicating a pre-2016 purchase).&amp;nbsp; If it is not, the find method returns a non-zero.&amp;nbsp; These are the cases kept for output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I repeat, this depends on records being sorted by date, or by date within cust_id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data is not sorted, then either it has to be sorted and submitted to the code above, or more complicated coding could be written for a single data step.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 03:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498035#M132223</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-09-22T03:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498131#M132283</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but when I run the code it says work.have created with 0 rows and 8 columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;please I am also attaching a sample data set if you can have a look&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 23:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498131#M132283</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2018-09-22T23:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498132#M132284</link>
      <description>&lt;P&gt;When I try it, it gives me the observations which took place after 2016. Irrespective of it being repeated in the previous year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to exclude products ordered by a customers more than once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say for example&lt;/P&gt;&lt;P&gt;in the attached excel sheet there are 10 products(highlighted in yellow) new to the customer(not ordered in their previous encounters). I want&amp;nbsp; those rows to be shown in the results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2018 23:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498132#M132284</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2018-09-22T23:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498143#M132291</link>
      <description>&lt;P&gt;Post the code and log from what you tried as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Sep 2018 01:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498143#M132291</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-23T01:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498144#M132292</link>
      <description>&lt;P&gt;95 proc sql;&lt;/P&gt;&lt;P&gt;96 create table want as&lt;/P&gt;&lt;P&gt;97 select a.*, b.order_date as prior_order_date&lt;/P&gt;&lt;P&gt;98 from work.a as a, work.a as b&lt;/P&gt;&lt;P&gt;99 where a.Cust_id = b.Cust_id&lt;/P&gt;&lt;P&gt;100 and a.Prod_id = b.Prod_id&lt;/P&gt;&lt;P&gt;101 and b.order_date in (2014,2015)&lt;/P&gt;&lt;P&gt;102 and a.order_date in (2016,2017);&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.WANT created, with 0 rows and 8 columns.&lt;/P&gt;&lt;P&gt;103 quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;</description>
      <pubDate>Sun, 23 Sep 2018 01:37:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498144#M132292</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2018-09-23T01:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498233#M132354</link>
      <description>&lt;P&gt;sort you data by customer Id and purchase date, prior to doing the proc sql process;&lt;/P&gt;&lt;P&gt;then those sql selections will work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Sep 2018 14:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498233#M132354</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-09-23T14:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498235#M132355</link>
      <description>Still no luck, table created with 0 observations and 7 rows&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;311 proc sort data=work.a;&lt;BR /&gt;&lt;BR /&gt;312 by order_date Cust_id;run;&lt;BR /&gt;&lt;BR /&gt;NOTE: There were 108 observations read from the data set WORK.A.&lt;BR /&gt;&lt;BR /&gt;NOTE: The data set WORK.A has 108 observations and 7 variables.&lt;BR /&gt;&lt;BR /&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;BR /&gt;&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;cpu time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;313 proc sql;&lt;BR /&gt;&lt;BR /&gt;314 create table S as&lt;BR /&gt;&lt;BR /&gt;315 select a.*, b.order_date as prior_order_date&lt;BR /&gt;&lt;BR /&gt;316 from work.a as a, work.a as b&lt;BR /&gt;&lt;BR /&gt;317 where a.Cust_id = b.Cust_id&lt;BR /&gt;&lt;BR /&gt;318 and a.prod_id = b.prod_id&lt;BR /&gt;&lt;BR /&gt;319 and b.order_date in (2014,2015)&lt;BR /&gt;&lt;BR /&gt;320 and a.order_date in (2016,2017);&lt;BR /&gt;&lt;BR /&gt;NOTE: Table WORK.S created, with 0 rows and 8 columns.&lt;BR /&gt;&lt;BR /&gt;321 quit;&lt;BR /&gt;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;cpu time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 23 Sep 2018 15:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498235#M132355</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2018-09-23T15:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498239#M132357</link>
      <description>&lt;P&gt;you need to obtain the year part from your date field.&amp;nbsp; your dates are in the format of mmddyy, where you need to test the year not the month a day parts of the date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Sep 2018 15:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498239#M132357</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-09-23T15:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498248#M132360</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Converted dates into year4. format, still no luck. I am sorry, I am naive at this doing it for the first time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;379 data year;&lt;/P&gt;&lt;P&gt;380 set work.a;&lt;/P&gt;&lt;P&gt;381 format order_date year4.;&lt;/P&gt;&lt;P&gt;382 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 108 observations read from the data set WORK.A.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.YEAR has 108 observations and 7 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;383 proc sort data=work.year;&lt;/P&gt;&lt;P&gt;384 by order_date cust_id;run;&lt;/P&gt;&lt;P&gt;NOTE: There were 108 observations read from the data set WORK.YEAR.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.YEAR has 108 observations and 7 variables.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;385 proc sql;&lt;/P&gt;&lt;P&gt;386 create table japan as&lt;/P&gt;&lt;P&gt;387 select a.*, b.order_date as prior_order_date&lt;/P&gt;&lt;P&gt;388 from work.year as a, work.year as b&lt;/P&gt;&lt;P&gt;389 where a.Cust_id = b.Cust_id&lt;/P&gt;&lt;P&gt;390 and a.Prod_id = b.Prod_id&lt;/P&gt;&lt;P&gt;391 and b.order_date in (2015)&lt;/P&gt;&lt;P&gt;392 and a.order_date in (2017);&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.JAPAN created, with 0 rows and 8 columns.&lt;/P&gt;&lt;P&gt;393 quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;</description>
      <pubDate>Sun, 23 Sep 2018 16:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498248#M132360</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2018-09-23T16:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498249#M132361</link>
      <description>&lt;P&gt;1st. switch your sort order to be by cust_id&amp;nbsp; order_date.&lt;/P&gt;&lt;P&gt;your question is customer based on order date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/235318"&gt;@ihtishamsultan&lt;/a&gt;&lt;/P&gt;&lt;P&gt;383 proc sort data=work.year;&lt;/P&gt;&lt;P&gt;384 by order_date cust_id;run;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;383 proc sort data=work.year;&lt;/P&gt;&lt;P&gt;384 by cust_id order_date ;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2nd. ensure the prior year is the correct year value you want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;do you really want to look back 2 years or can you look back only 1 year? &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/235318"&gt;@ihtishamsultan&lt;/a&gt;has 2015 for prior lookup records in 2017, but in your original request criteria 2014 and 2015 where the prior years to look for when finding current records for 2016 and 2017.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/235318"&gt;@ihtishamsultan&lt;/a&gt;&lt;/P&gt;&lt;P&gt;391 and b.order_date in (2015)&lt;/P&gt;&lt;P&gt;392 and a.order_date in (2017);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VDD says Try this&lt;/P&gt;&lt;P&gt;391 and b.order_date in (2014,2015)&lt;/P&gt;&lt;P&gt;392 and a.order_date in (2017);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you may not want to look back 3 years based on the original requirements statement in your request.&amp;nbsp; If not then drop the 2014 that I have above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Sep 2018 16:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498249#M132361</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-09-23T16:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get product count which are new to customers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498251#M132363</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for being patient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not currently have access to the orignal dataset the person gave me this sample dataset to try the code on, this data set has entries from 2017 and 2015 to simplify it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as per your advise I sorted the dataset by cust_id and then order_date; and tried running it again and it gives me 0 rows and 7 columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;379 data year;&lt;/P&gt;&lt;P&gt;380 set work.a;&lt;/P&gt;&lt;P&gt;381 format order_date year4.;&lt;/P&gt;&lt;P&gt;382 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 108 observations read from the data set WORK.A.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.YEAR has 108 observations and 7 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;383 proc sort data=work.year;&lt;/P&gt;&lt;P&gt;384 by order_date cust_id;run;&lt;/P&gt;&lt;P&gt;NOTE: There were 108 observations read from the data set WORK.YEAR.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.YEAR has 108 observations and 7 variables.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;385 proc sql;&lt;/P&gt;&lt;P&gt;386 create table japan as&lt;/P&gt;&lt;P&gt;387 select a.*, b.order_date as prior_order_date&lt;/P&gt;&lt;P&gt;388 from work.year as a, work.year as b&lt;/P&gt;&lt;P&gt;389 where a.Cust_id = b.Cust_id&lt;/P&gt;&lt;P&gt;390 and a.Prod_id = b.Prod_id&lt;/P&gt;&lt;P&gt;391 and b.order_date in (2015)&lt;/P&gt;&lt;P&gt;392 and a.order_date in (2017);&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.JAPAN created, with 0 rows and 8 columns.&lt;/P&gt;&lt;P&gt;393 quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;</description>
      <pubDate>Sun, 23 Sep 2018 17:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-product-count-which-are-new-to-customers/m-p/498251#M132363</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2018-09-23T17:03:46Z</dc:date>
    </item>
  </channel>
</rss>

