<?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: Creating values for missing data to enable summary statistics in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543402#M33272</link>
    <description>&lt;P&gt;You would better calculate the status duration (number of days) and use that as a FREQ variable in summary procedures. Get the duration by lookahead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set sample_data; by account_id;
if not last then
    set sample_data(firstobs=2 keep=status_date rename=status_date=next_date) end=last;
if last.account_id then status_duration = 1; /* Default duration */ 
else status_duration = next_date - status_date;
drop next_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 15 Mar 2019 03:48:43 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2019-03-15T03:48:43Z</dc:date>
    <item>
      <title>Creating values for missing data to enable summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543294#M33268</link>
      <description>&lt;P&gt;GA everyone,&lt;/P&gt;&lt;P&gt;I have an existing customer status data set that is only updated when a status change change occurs.&amp;nbsp; I want to do status counts by month, year and segment.&amp;nbsp; So the challenge is creating a temp table for missing values for the month date periods that are not in the data table in order to enable a count of status by month and year.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Important assumption:&lt;/P&gt;&lt;P&gt;- Customer_Status is the same when it is not reported&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I should be able to count status for the Status_Date that are missing for Company02&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dates Missing&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Assumed Status&lt;/P&gt;&lt;P&gt;05/01/2005 -&amp;nbsp; 05/31/2009&amp;nbsp; Active&lt;/P&gt;&lt;P&gt;07/01/2009 -&amp;nbsp; 09/31/2009&amp;nbsp; CYRisk&lt;/P&gt;&lt;P&gt;11/01/2009 -&amp;nbsp; 07/31/2013&amp;nbsp; Active&lt;/P&gt;&lt;P&gt;09/01/2013 - Today()&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CYRisk&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Data&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sample_data;&lt;BR /&gt;input @1 Account_id 2.&lt;BR /&gt;@3 Account_name $10.&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83330"&gt;@13&lt;/a&gt;Segment $14.&lt;BR /&gt;@28 Customer_Status 2.&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/75109"&gt;@30&lt;/a&gt;Customer_Status_Name $7.&lt;BR /&gt;+1 Status_Date mmddyy10.;&lt;BR /&gt;format Status_Date mmddyy10.;&lt;BR /&gt;cards;&lt;BR /&gt;02 Company01 HighNewtWorth 04 CPLost 12/05/2006&lt;BR /&gt;03 Company02 MidSizeMarket 01 Active 04/25/2005&lt;BR /&gt;03 Company02 MidSizeMarket 08 CYRisk 06/25/2009&lt;BR /&gt;03 Company02 MidSizeMarket 01 Active 10/05/2009&lt;BR /&gt;03 Company02 MidSizeMarket 08 CYRisk 08/09/2013&lt;BR /&gt;04 Company03 HighNewtWorth 01 Active 01/26/2005&lt;BR /&gt;04 Company03 HighNewtWorth 04 CPLost 12/02/2016&lt;BR /&gt;05 Company04 HighNewtWorth 01 Active 09/13/2004&lt;BR /&gt;06 Company05 HighNewtWorth 01 Active 10/01/2004&lt;BR /&gt;06 Company05 HighNewtWorth 02 Inactv 08/18/2011&lt;BR /&gt;07 Company06 HighNewtWorth 01 Active 09/06/2006&lt;BR /&gt;08 Company07 HighNewtWorth 01 Active 08/01/2005&lt;BR /&gt;09 Company08 HighNewtWorth 01 Active 11/01/2005&lt;BR /&gt;09 Company08 HighNewtWorth 02 Inactv 11/23/2010&lt;BR /&gt;09 Company08 HighNewtWorth 06 Termin 05/07/2011&lt;BR /&gt;10 Company09 HighNewtWorth 01 Active 07/31/2007&lt;BR /&gt;10 Company09 HighNewtWorth 11 Infreq 10/27/2011&lt;BR /&gt;10 Company09 HighNewtWorth 01 Active 11/02/2012&lt;BR /&gt;10 Company09 HighNewtWorth 11 Infreq 11/14/2018&lt;BR /&gt;11 Company10 HighNewtWorth 01 Active 01/04/2005&lt;BR /&gt;11 Company10 HighNewtWorth 04 CPLost 06/05/2015&lt;BR /&gt;12 Company11 HighNewtWorth 01 Active 10/26/2004&lt;BR /&gt;13 Company12 HighNewtWorth 01 Active 01/14/2005&lt;BR /&gt;13 Company12 HighNewtWorth 02 Inactv 07/21/2011&lt;BR /&gt;14 Company13 HighNewtWorth 01 Active 01/04/2005&lt;BR /&gt;14 Company13 HighNewtWorth 02 Inactv 08/02/2012&lt;BR /&gt;15 Company14 HighNewtWorth 01 Active 09/01/2005&lt;BR /&gt;15 Company14 HighNewtWorth 02 Inactv 09/19/2008&lt;BR /&gt;16 Company15 HighNewtWorth 01 Active 09/28/2006&lt;BR /&gt;17 Company15 HighNewtWorth 06 Termin 05/19/2005&lt;BR /&gt;18 Company16 HighNewtWorth 01 Active 02/11/2005&lt;BR /&gt;19 Company17 HighNewtWorth 01 Active 10/26/2004&lt;BR /&gt;20 Company18 HighNewtWorth 01 Active 08/24/2005&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 19:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543294#M33268</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2019-03-14T19:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating values for missing data to enable summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543402#M33272</link>
      <description>&lt;P&gt;You would better calculate the status duration (number of days) and use that as a FREQ variable in summary procedures. Get the duration by lookahead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set sample_data; by account_id;
if not last then
    set sample_data(firstobs=2 keep=status_date rename=status_date=next_date) end=last;
if last.account_id then status_duration = 1; /* Default duration */ 
else status_duration = next_date - status_date;
drop next_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Mar 2019 03:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543402#M33272</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-15T03:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating values for missing data to enable summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543547#M33278</link>
      <description>&lt;P&gt;Thank you for the quick turnaround, this works as intended but given how I need to use the data, I really need to retain the values and assumed status for each identified missing date that is created as I will be doing multiple date range analysis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In data set&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 01 Active 04/25/2005&lt;BR /&gt;03 Company02 MidSizeMarket 08 CYRisk 06/25/2009&lt;BR /&gt;03 Company02 MidSizeMarket 01 Active 10/05/2009&lt;BR /&gt;03 Company02 MidSizeMarket 08 CYRisk 08/09/2013&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Required output&lt;/P&gt;&lt;P&gt;-keeps the original value and produces the missing data, just listing a few records that would be created&amp;nbsp; between observations&amp;nbsp; for Company02&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;03 Company02 MidSizeMarket 01 Active 04/25/2005 - original&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 01 Active 05/01/2005 - created&amp;nbsp;&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 01 Active 06/01/2005 - created&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 01 Active 07/01/2005 - created&amp;nbsp;&lt;/P&gt;&lt;P&gt;until we reach month b4 next status date&amp;nbsp;&lt;STRONG&gt;05/01/2009&lt;/STRONG&gt; - created&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;03 Company02 MidSizeMarket 08 CYRisk 06/25/2009 - original&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 08 CYRisk 07/01/2009 - created&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 08 CYRisk 08/01/2009 - created&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 08 CYRisk 09/01/2009 - created&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;03 Company02 MidSizeMarket 01 Active 10/05/2009&amp;nbsp; - original&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 01 Active 11/01/2009&amp;nbsp; - created&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 01 Active 12/01/2009 - created&amp;nbsp;&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 01 Active 12/01/2009 - created&amp;nbsp;&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 01 Active 01/01/2010 - created&amp;nbsp;&lt;/P&gt;&lt;P&gt;until we reach month b4 next status date&amp;nbsp;&lt;STRONG&gt;07/01/2013&lt;/STRONG&gt; - created&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;03 Company02 MidSizeMarket 08 CYRisk 08/09/2013 - original&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;03 Company02 MidSizeMarket 08 CYRisk 09/09/2013 - created&lt;/P&gt;&lt;P&gt;---------------------until we reach most recent mm/01/yyyy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm standardizing the output to day 01 for new date, hope this makes sense&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 14:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543547#M33278</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2019-03-15T14:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating values for missing data to enable summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543573#M33279</link>
      <description>&lt;P&gt;This will build you a table that I think you can use to generate whatever transactions you need to complete your list of accounts and months.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Get the Accounts */
proc sql noprint;
	create table Check_Accounts as
		select distinct Account_id as Check_Account from Sample_Data;
quit;

/* Get the earliest and latest date */
proc sql noprint;
	select min(Status_Date), max(Status_Date) into :Min_Date, :Max_Date
		from Sample_Data;

	/* Get a list of all the needed dates */
data Check_Months(drop=_:);
	_Number_Of_Months = intck('month', &amp;amp;Min_Date., &amp;amp;Max_Date.);

	do _i = 0 to _Number_Of_Months;
		Check_Month = intnx("month", &amp;amp;Min_Date., _i, 'beginning');
		format Check_Month date.;
		output;
	end;
run;

/* Get a cross-combination of accounts and dates */
proc sql noprint;
	create table Check_Table as select Check_Account, Check_Month, 'Missing' as Check_Status from Check_Accounts cross join Check_Months;
quit;

/* Get the Account and Month */
data Existing_Company_Month;
	set Sample_Data;
	Month_Active = intnx("month", Status_Date, 0, 'beginning');
	format Month_Active date.;
	keep Account_id Month_Active;
run;

/* Sort, and then keep the first (get unique) */
proc sort data=Existing_Company_Month;
	by Account_id Month_Active;
run;

data Existing_Company_Month;
	set Existing_Company_Month;
	by Account_id Month_Active;
	Current_Status = "Active";

	if first.Month_Active then
		output;
run;

/* Join the two tables to figure out which months we have and which ones we need to add data for */
proc sql noprint;
	create table Combined_Tables as select m.*, e.Current_Status
		from Check_Table m left outer join Existing_Company_Month e
			on(m.Check_Account = e.Account_id and m.Check_Month = e.Month_Active)
		order by m.Check_Account, m.Check_Month;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Mar 2019 15:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543573#M33279</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2019-03-15T15:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating values for missing data to enable summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543597#M33280</link>
      <description>&lt;P&gt;OK. You asked for it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set sample_data; by account_id;
if not last then
    set sample_data(firstobs=2 keep=status_date rename=status_date=next_date) end=last;
if last.account_id then output;
else do status_date = status_date to next_date - 1; output; end;
drop next_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Mar 2019 17:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Creating-values-for-missing-data-to-enable-summary-statistics/m-p/543597#M33280</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-15T17:32:42Z</dc:date>
    </item>
  </channel>
</rss>

