<?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: Comparing &amp;quot;year to date&amp;quot; data and identifying new obs by month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472663#M121219</link>
    <description>&lt;P&gt;it is all comparing to the end of 2017 book of business. So new would be considered any company&amp;nbsp;that is not in December of 17 but is in any other month. Cancelled is any company&amp;nbsp;that was in December of 17 but not in any month since. &amp;nbsp;Retained would be any company&amp;nbsp;that is in December of 2017 and the most current month.&lt;/P&gt;</description>
    <pubDate>Sat, 23 Jun 2018 02:57:21 GMT</pubDate>
    <dc:creator>huffa9299</dc:creator>
    <dc:date>2018-06-23T02:57:21Z</dc:date>
    <item>
      <title>Comparing "year to date" data and identifying new obs by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472660#M121216</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a portfolio table that include general info about client companies by month. I am trying to&amp;nbsp;sum&amp;nbsp;employees grouped&amp;nbsp;by product,&amp;nbsp;within&amp;nbsp;new, cancelled, and retained business.&amp;nbsp;The table&amp;nbsp;looks similar to the below dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Company&lt;/TD&gt;&lt;TD&gt;product&lt;/TD&gt;&lt;TD&gt;Employees&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;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TD&gt;201802&lt;/TD&gt;&lt;TD&gt;Charlie&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;205&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201802&lt;/TD&gt;&lt;TD&gt;Delta&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;110&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My end goal is to create reports based on the sum of employees by product, for&amp;nbsp;retained, new, and cancelled business. For example, compared to December of 2017, January of 2018 has one new company (Charlie) with 200 employees in&amp;nbsp;product X. Company Alpha gained 2 employees in both product&amp;nbsp;X and Y. And company Bravo lost 10 employees&amp;nbsp;with product&amp;nbsp;X.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to identify&amp;nbsp;new, cancelled, and retained business by product compared to the starting month? If anyone is aware of any documentation on what the best practices are to do this analysis, id be more than willing to read any suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jun 2018 13:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472660#M121216</guid>
      <dc:creator>huffa9299</dc:creator>
      <dc:date>2018-06-24T13:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing "year to date" data and identifying new obs by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472662#M121218</link>
      <description>&lt;P&gt;So what is your definition of a new, cancelled or retained business based on the data you have provided?&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jun 2018 02:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472662#M121218</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-06-23T02:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing "year to date" data and identifying new obs by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472663#M121219</link>
      <description>&lt;P&gt;it is all comparing to the end of 2017 book of business. So new would be considered any company&amp;nbsp;that is not in December of 17 but is in any other month. Cancelled is any company&amp;nbsp;that was in December of 17 but not in any month since. &amp;nbsp;Retained would be any company&amp;nbsp;that is in December of 2017 and the most current month.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jun 2018 02:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472663#M121219</guid>
      <dc:creator>huffa9299</dc:creator>
      <dc:date>2018-06-23T02:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing "year to date" data and identifying new obs by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472666#M121220</link>
      <description>&lt;P&gt;Dec 2017 doesn't appear in your posted data. Can you provide a more complete set of data to test on that includes your reference month? It is best if you can provide it in a DATA step using a CARDS or DATALINES statement.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jun 2018 03:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472666#M121220</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-06-23T03:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing "year to date" data and identifying new obs by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472668#M121221</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137911"&gt;@huffa9299&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Please provide sample data which cover all your conditions. What you've posted so far doesn't have a single record for 201712.&lt;/P&gt;
&lt;P&gt;Please post such data in the form of a SAS data step and ideally also show us the desired result. It's not clear to me where you would flag a company as "cancelled" as for this company there isn't a record in the source to flag.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here the data step creating the sample data you've posted so far for you to amend.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dlm=' ' truncover;
  input Date:yymmn6. Company $ product $ Employees;
  format date date9.;
  datalines;
201701 Alpha X 60
201701 Alpha Y 60
201701 Bravo X 100
201801 Alpha X 62
201801 Alpha Y 62
201801 Bravo X 90
201801 Charlie X 200
201802 Alpha X 65
201802 Alpha Y 65
201802 Charlie Y 205
201802 Delta X 110
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jun 2018 03:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472668#M121221</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-06-23T03:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing "year to date" data and identifying new obs by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472832#M121276</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;I apologize&amp;nbsp;for the confusion-slight typo above. I meant to have the starting month in the dataset be 201712. I have corrected this mistake! Under the assumption&amp;nbsp;we are comparing everything to the first month in the dataset (201712),&amp;nbsp;I am&amp;nbsp;trying to make 3 summary reports:&lt;/P&gt;&lt;P&gt;-New business (Any company that was not listed in Dec17&amp;nbsp;but is listed in the most recent month)&lt;/P&gt;&lt;P&gt;-Cancelled business (Any company that is listed in Dec17 but is no longer listed in the most recent month)&lt;/P&gt;&lt;P&gt;-Retained business (Any company that is listed in both Dec17 and the most recent month)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to end up with something similar to the&amp;nbsp;report created with the below code, but if possible, I would like it for new, cancelled, and retained business that match the criteria above.&amp;nbsp; I am trying to see which products we are selling, losing, and retaining over the course of a year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dlm=' ' truncover;
  input Date:yymmn6. Company $ product $ Employees;
  format date date9.;
  datalines;
201712 Alpha X 60
201712 Alpha Y 60
201712 Bravo X 100
201801 Alpha X 62
201801 Alpha Y 62
201801 Bravo X 90
201801 Charlie X 200
201802 Alpha X 65
201802 Alpha Y 65
201802 Charlie Y 205
201802 Delta X 110
;
run;
proc sort data=have;
by product;
run;

proc report data=have;
column Date Employees;
define date / group;&lt;BR /&gt;rbreak after / summarize;
by product;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Does that make more sense?&amp;nbsp; If not, please let me know and I can try to better explain. I appreciate your help with this!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jun 2018 22:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472832#M121276</guid>
      <dc:creator>huffa9299</dc:creator>
      <dc:date>2018-06-24T22:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing "year to date" data and identifying new obs by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472840#M121282</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137911"&gt;@huffa9299&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Something like below could prepare your data for reporting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dlm=' ' truncover;
  input Date:yymmn6. Company $ product $ Employees;
  format date date9.;
  datalines;
201712 Alpha X 60
201712 Alpha Y 60
201712 Bravo X 100
201801 Alpha X 62
201801 Alpha Y 62
201801 Bravo X 90
201801 Charlie X 200
201802 Alpha X 65
201802 Alpha Y 65
201802 Charlie Y 205
201802 Delta X 110
;
run;

proc sql noprint;
  select put(max(date),date9. -l) into :max_date
  from have;
quit;

proc sort data=have out=inter;
  by Company Date;
run;

proc format;
  value compStatus(default=9)
  1='Retained'
  2='New'
  3='Cancelled'
  ;
quit;

data want(drop=_:);
  merge 
    inter(in=exist2017 keep=Company date rename=(date=_date2017) where=(_date2017='01Dec2017'd)) 
    inter(in=exist2018 keep=Company date rename=(date=_date2018) where=(_date2018="&amp;amp;max_date"d)) 
    inter
    ;
  by Company;

  format status_flg compStatus.;
  if exist2017 and exist2018 then status_flg=1;
  else if not exist2017 and exist2018 then status_flg=2;
  else if exist2017 and not exist2018 then status_flg=3;

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jun 2018 23:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/472840#M121282</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-06-24T23:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing "year to date" data and identifying new obs by month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/473149#M121380</link>
      <description>Works great Patrick! Thank you for your help!!</description>
      <pubDate>Mon, 25 Jun 2018 19:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-quot-year-to-date-quot-data-and-identifying-new-obs-by/m-p/473149#M121380</guid>
      <dc:creator>huffa9299</dc:creator>
      <dc:date>2018-06-25T19:59:04Z</dc:date>
    </item>
  </channel>
</rss>

