<?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 determine whether a customer has skipped a month%3F in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716050#M221236</link>
    <description>&lt;P&gt;Is that exactly how your data appears, where month is a 3-letter abbreviation? This is a very poor way to represent month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make your life much simpler, change month from a 3-letter character string to an actual numeric SAS date, and then the problem is simple. Otherwise, you have to write a program that knows Apr comes &lt;STRONG&gt;AFTER&lt;/STRONG&gt; Mar (and all the other combinations), and also arranging data with 3-letter abbreviations utterly fails at year boundaries.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Feb 2021 12:44:13 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-02-02T12:44:13Z</dc:date>
    <item>
      <title>How to determine whether a customer has skipped a month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716049#M221235</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question is how do I determine whether a customer does not appear in a month? For example:&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Month&lt;/TD&gt;
&lt;TD&gt;Customer ID&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Jan&lt;/TD&gt;
&lt;TD&gt;a&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Jan&lt;/TD&gt;
&lt;TD&gt;b&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Feb&lt;/TD&gt;
&lt;TD&gt;a&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Feb&lt;/TD&gt;
&lt;TD&gt;b&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Mar&lt;/TD&gt;
&lt;TD&gt;a&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Apr&lt;/TD&gt;
&lt;TD&gt;a&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Apr&lt;/TD&gt;
&lt;TD&gt;b&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;May&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;a&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;May&lt;/TD&gt;
&lt;TD&gt;b&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, how do I determine that customer "b" skipped March?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 14:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716049#M221235</guid>
      <dc:creator>Giraffe123</dc:creator>
      <dc:date>2021-02-02T14:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine whether a customer has skipped a month%3F</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716050#M221236</link>
      <description>&lt;P&gt;Is that exactly how your data appears, where month is a 3-letter abbreviation? This is a very poor way to represent month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make your life much simpler, change month from a 3-letter character string to an actual numeric SAS date, and then the problem is simple. Otherwise, you have to write a program that knows Apr comes &lt;STRONG&gt;AFTER&lt;/STRONG&gt; Mar (and all the other combinations), and also arranging data with 3-letter abbreviations utterly fails at year boundaries.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 12:44:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716050#M221236</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-02T12:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine whether a customer has skipped a month%3F</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716053#M221238</link>
      <description>Hi Paige&lt;BR /&gt;&lt;BR /&gt;Thanks for your quick reply. My month variable is in "date" format, sorry for not including that in my question.</description>
      <pubDate>Tue, 02 Feb 2021 12:52:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716053#M221238</guid>
      <dc:creator>Giraffe123</dc:creator>
      <dc:date>2021-02-02T12:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine whether a customer has skipped a month%3F</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716058#M221240</link>
      <description>&lt;P&gt;not having your data, i think this code ought to work.&amp;nbsp; you may need to tweak it a bit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE WORK.Want AS
SELECT b.*
FROM
	work.have a
	FULL OUTER JOIN 
	(
		SELECT *
		FROM (SELECT DISTINCT Month FROM work.have) a
		CROSS JOIN (SELECT DISTINCT CustomerID FROM work.have) between
	) b	 
WHERE
	a.CustomerID is null
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Feb 2021 13:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716058#M221240</guid>
      <dc:creator>utrocketeng</dc:creator>
      <dc:date>2021-02-02T13:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine whether a customer has skipped a month%3F</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716059#M221241</link>
      <description>&lt;P&gt;Thanks for the question, normally we would want you as a customer to be able to do this yourself. I would highly recommend taking the&amp;nbsp;some more Advanced SAS training. In this case I would suggest a SAS Programming 3 course. Obviously, if you have taken the SAS Programming 2 course first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data customer; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile cards;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input Month $ Customer $;&lt;/P&gt;
&lt;P&gt;cards;&lt;BR /&gt;Jan a&lt;BR /&gt;Jan b&lt;BR /&gt;Feb a&lt;BR /&gt;Feb b&lt;BR /&gt;Mar a&lt;BR /&gt;Apr a&lt;BR /&gt;Apr b&lt;BR /&gt;May a&lt;BR /&gt;May b&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=customer out=customersorted;&lt;BR /&gt;&amp;nbsp; by customer;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data customernotinmonths(keep=customer month);&lt;BR /&gt;&amp;nbsp; set customersorted end=eof;&lt;BR /&gt;&amp;nbsp; by customer ;&lt;BR /&gt;&amp;nbsp; Array Months(12) $ ("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec");&lt;BR /&gt;&amp;nbsp; Array mthchk(12);&lt;BR /&gt;&amp;nbsp; Retain mthchk1-mthchk12;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp; if first.customer then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;do i=1 to dim(mthchk);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; mthchk(i)=0;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;do j=1 to dim(months);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if month=months(j) then mthchk(j)=1;&lt;BR /&gt;&amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if last.customer then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;do x=1 to dim(mthchk);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if mthchk(x)=0 then &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; month=months(x);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 13:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716059#M221241</guid>
      <dc:creator>CarmineVerrell</dc:creator>
      <dc:date>2021-02-02T13:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine whether a customer has skipped a month%3F</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716060#M221242</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/258785"&gt;@Giraffe123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Paige&lt;BR /&gt;&lt;BR /&gt;Thanks for your quick reply. My month variable is in "date" format, sorry for not including that in my question.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sure what this means. Does this mean that month is a numeric value which is a true SAS date (which is the number of days since 1-1-1960)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will get faster and better answers when you provide the data in the form it exists in your data sets, rather than 3-letter abbreviations which is not how the data exists in your data sets. Can you provide the data following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 13:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716060#M221242</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-02T13:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine whether a customer has skipped a month%3F</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716062#M221243</link>
      <description>&lt;P&gt;Do you need consider YEAR ?&amp;nbsp; better post your real data,not just format value .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards expandtabs truncover;
input Month : monyy7.	CustomerID $;
format month monyy7.;
cards;
Jan2010	a
Jan2010	b
Feb2010	a
Feb2010	b
Mar2010	a
Apr2010	a
Apr2010	b
May2010 a
May2010	b
;

proc sql;
create table want as
select b.*,not missing(a.month) as is_in_have
 from have as a right join
 (select * from (select distinct month from have),(select distinct CustomerID from have)) as b
 on a.month=b.month and a.CustomerID=b.CustomerID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Feb 2021 13:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-determine-whether-a-customer-has-skipped-a-month/m-p/716062#M221243</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-02-02T13:15:32Z</dc:date>
    </item>
  </channel>
</rss>

