<?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 observations for missing values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388623#M65944</link>
    <description>&lt;P&gt;ID &amp;nbsp; Year &amp;nbsp; &amp;nbsp;Qtr &amp;nbsp; Spent &amp;nbsp;Date of Entry&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan 2011&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;100 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100 &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200 &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So for the 3 year bubble I have a year of lookback, the year during and the year after the entry date.And I have this for each observation, with each obersvation having a different date of entry. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Aug 2017 21:10:34 GMT</pubDate>
    <dc:creator>endofline</dc:creator>
    <dc:date>2017-08-16T21:10:34Z</dc:date>
    <item>
      <title>Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388594#M65931</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm working with some price data that is summed up by the year and the fiscal quarter. However, not all observations have purchases in all quarters/years. I want to make those missing quarters/year appear as a 0. I have a 3 year bubble around each of my observations where I have data on what they spent.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently this is how my data looks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp; Year &amp;nbsp; &amp;nbsp;Qtr &amp;nbsp; Spent&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;100&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp; Year &amp;nbsp; &amp;nbsp;Qtr &amp;nbsp; Spent&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;100&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; 2012 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; 2012 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2012 &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2012 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&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;</description>
      <pubDate>Wed, 16 Aug 2017 20:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388594#M65931</guid>
      <dc:creator>endofline</dc:creator>
      <dc:date>2017-08-16T20:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388595#M65932</link>
      <description>&lt;P&gt;If you have SAS/ETS look at PROC TIMESERIES&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388595#M65932</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-16T20:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388598#M65933</link>
      <description>&lt;P&gt;I believe that I have proc timeseries, but have never used it. How would you use it to create what I need?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388598#M65933</guid>
      <dc:creator>endofline</dc:creator>
      <dc:date>2017-08-16T20:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388599#M65934</link>
      <description>&lt;P&gt;If you have to do it yourself without ETS, it's not that lengthy.&amp;nbsp; First, create a data set with all combinations of ID, YEAR, and QTR:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table year_list as select distinct year from have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table id_list as select distinct id from have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table qtr_list as select distinct qtr from have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table all_combinations as select * from year_list, id_list, qtr_list;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then sort, merge, fill in the zeros:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=all_combinations;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by id year qtr;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by id year qtr;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; merge all_combinations have (in=have_data);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by id year qtr;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if have_data=0 then spent=0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388599#M65934</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-16T20:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388601#M65935</link>
      <description>&lt;P&gt;You specify the time interval, the start and end period and it fills it in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure to include your BY statement as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a fully worked example with fake data:&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;/*this is an example of time series data. 
1. Create a time series data set with missing intervals (IBM)
2. Add back missing entries using PROC TIMESERIES (IBM_NO_MISSING)
3. Calculate moving average - 12 month average
*/

/*1*/
data ibm;
	set sashelp.stocks;
	where stock='IBM';

	if month(date)=7 then
		delete;
run;

proc sort data=ibm;
	by date;
run;

/*2*/
proc timeseries data=ibm out=ibm_no_missing;
	id date interval=month start='01Aug1986'd end='01Dec2005'd;
	var open;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388601#M65935</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-16T20:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388610#M65936</link>
      <description>&lt;P&gt;For the example you posted where it has&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;start&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token datetime number"&gt;'01Aug1986'd&lt;/SPAN&gt; end&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token datetime number"&gt;'01Dec2005'd&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this the overall global start and end date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way I get the data is that I have a 3 year bubble around each ID as they enter into my data. However, not all of them are entering in at the same time, some might enter in 2010 and others in 2013.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388610#M65936</guid>
      <dc:creator>endofline</dc:creator>
      <dc:date>2017-08-16T20:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388615#M65938</link>
      <description>&lt;P&gt;Ah...then this method won't work, you'll need to use the data step approach. If you have a &amp;nbsp;data set that defines the bubbles it's relatively straightforward to loop the dates to get an empty table with all the records and then merge it in with the original table to get the results.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 20:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388615#M65938</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-16T20:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388618#M65939</link>
      <description>&lt;P&gt;OK, how might you go about that then? I was thinking about something with loops but could not think of a solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388618#M65939</guid>
      <dc:creator>endofline</dc:creator>
      <dc:date>2017-08-16T21:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388619#M65940</link>
      <description>&lt;P&gt;What data do you have? If all you have is what you've shown above, how do you know what the start and end of the loop will be?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388619#M65940</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-16T21:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388620#M65941</link>
      <description>&lt;P&gt;So this will work but it does still have some issues. My data goes from 2009 to 2015. but not all IDs are coming in during the same time frame. Some are coming in 2010 and others in 2013 and I just want to be able to capture the 3 year bubble around them. I tried this solution but it gives me the full 2009 to 2015 time frame around all of the IDs. Any thoughts on how to get it to just be around the 3 year bubble?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388620#M65941</guid>
      <dc:creator>endofline</dc:creator>
      <dc:date>2017-08-16T21:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388621#M65942</link>
      <description>&lt;P&gt;I have the variables I showed, ID, Yr, Qtr and Spent plus the start date of when they entered so:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp; Year &amp;nbsp; &amp;nbsp;Qtr &amp;nbsp; Spent &amp;nbsp;Date of Entry&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan 2011&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;100 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100 &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200 &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So I have a year of lookback, the year during and the year after the entry date.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388621#M65942</guid>
      <dc:creator>endofline</dc:creator>
      <dc:date>2017-08-16T21:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388622#M65943</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49964"&gt;@endofline&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;Any thoughts on how to get it to just be around the 3 year bubble?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What's a 3 year bubble? As long as you can define it, you're fine, so far you haven't offered a definition.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388622#M65943</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-16T21:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388623#M65944</link>
      <description>&lt;P&gt;ID &amp;nbsp; Year &amp;nbsp; &amp;nbsp;Qtr &amp;nbsp; Spent &amp;nbsp;Date of Entry&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jan 2011&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;100 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2010 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100 &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2011 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200 &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Jan 2011&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So for the 3 year bubble I have a year of lookback, the year during and the year after the entry date.And I have this for each observation, with each obersvation having a different date of entry. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388623#M65944</guid>
      <dc:creator>endofline</dc:creator>
      <dc:date>2017-08-16T21:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388626#M65946</link>
      <description>&lt;P&gt;You'll have to describe the date ranges a little more.&amp;nbsp; (And of course the program gets more complex.)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could a company begin in Q3 of one year, and end in Q2 of another year?&amp;nbsp; How do you know when the window begins and ends for each company?&amp;nbsp; Does a window have to be exactly 12 quarters, or does it depend on the data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll be able to compare my questions to your (just-posted) description later tonight.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388626#M65946</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-16T21:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388627#M65947</link>
      <description>&lt;P&gt;I know when they enter in the data set for sure by the date entered variable and that we're for sure suppose to be getting 1 year of lookback data from that entry date, the year during and the year after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does happen that someone does enter in the dataset in say April or October. However, it should be 12 qtrs.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388627#M65947</guid>
      <dc:creator>endofline</dc:creator>
      <dc:date>2017-08-16T21:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388634#M65948</link>
      <description>&lt;P&gt;Use&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;'s logic but create the all_combinations with the next code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table temp1 as 
      select distinct id, date_of_entry;
quit;

data all_combinations;
  set temp1;
        start_year = year(date_of_entry) - 1; 
              /* change if needed accoring to date_of_entry format */
        do year = start_year to (start_year +2);
            do qtr=1 to 4;
                 output;
        end; end;&lt;BR /&gt;        keep id year qtr date_of_entry;   /* or drop start_year */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;continue with code of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;(sort, merge, replace missing spent by 0).&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388634#M65948</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-16T21:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388635#M65949</link>
      <description>&lt;P&gt;I'm afraid&amp;nbsp;I haven't read through the thread as I am feeling very lazy. However, for your sample HAVE and WANT, and here you go:&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;&lt;STRONG&gt;data&lt;/STRONG&gt; have;&lt;/P&gt;&lt;P&gt;input ID&amp;nbsp;&amp;nbsp; Year&amp;nbsp;&amp;nbsp;&amp;nbsp; Qtr&amp;nbsp;&amp;nbsp; Spent;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 25&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2011&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2011&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;/P&gt;&lt;P&gt;;&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;&lt;STRONG&gt;data&lt;/STRONG&gt; want;&lt;/P&gt;&lt;P&gt;do until(last.id);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=&lt;STRONG&gt;1&lt;/STRONG&gt; by &lt;STRONG&gt;1&lt;/STRONG&gt; until(last.year);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by id year;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if first.year then _qtr=qtr;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _n_=&lt;STRONG&gt;1&lt;/STRONG&gt; and qtr ne _n_ then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _qtr=qtr;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _spent=spent;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do qtr=_n_ to qtr-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;spent=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;spent=_spent;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;_qtr=qtr;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if _qtr ne qtr then&lt;/P&gt;&lt;P&gt;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _spent=spent;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do qtr=_qtr+&lt;STRONG&gt;1&lt;/STRONG&gt; to qtr-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spent=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spent=_spent;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _qtr=qtr;&lt;/P&gt;&lt;P&gt;&amp;nbsp;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;else output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop _:;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&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;</description>
      <pubDate>Wed, 16 Aug 2017 22:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388635#M65949</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-08-16T22:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388791#M65965</link>
      <description>&lt;P&gt;It is very easy for SQL.&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;
input ID   Year    Qtr   Spent ;
cards;
1    2010   1       50
1    2010   2      100 
1    2010   4        25
1    2011   2        100
1    2011   4        200
;
run;
data qtr;
 do qtr=1 to 4;
  output;
 end;
run;

proc sql;
create table want as
 select  a.*,coalesce(spent,0) as spent
  from
  (
select * from
(select distinct id from have),
(select distinct year from have),
(select distinct qtr from qtr)
) as a 
left join have as b
on a.id=b.id and a.year=b.year and a.qtr=b.qtr ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 13:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388791#M65965</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-08-17T13:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388932#M65988</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp; Thank you. It's something very intriguing to read your brilliant innovative solutions. I wish I had the drive to be keen, driven and dedicated as you are however I am too lazy to venture into much learning and applying. My bad. Thank you for making me think. Cheers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen Srinivasan&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 18:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388932#M65988</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-08-17T18:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating observations for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388939#M65989</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;your participation on here would indicate the opposite &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;I wish I had the drive to be keen, driven and dedicated as you are however I am too lazy to venture into much learning and applying. My bad. Thank you for making me think.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 19:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-observations-for-missing-values/m-p/388939#M65989</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-17T19:14:24Z</dc:date>
    </item>
  </channel>
</rss>

