<?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 populate missing observations with the next available observation? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713875#M220311</link>
    <description>data want;&lt;BR /&gt; merge have have(keep=ticker fiscal_year_end  where=(fiscal_year_end is not missing));&lt;BR /&gt;by ticker;&lt;BR /&gt;run;</description>
    <pubDate>Mon, 25 Jan 2021 11:57:55 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-01-25T11:57:55Z</dc:date>
    <item>
      <title>How to populate missing observations with the next available observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713783#M220262</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;I have a dataset where I need to populate each observation with which fiscal year they belong to. Each company has the fiscal year end populated as below, but I need every observation to be matched with its appropriate year-end. Essentially, if it's empty, I want it to capture the next available observation. Is there any way I could do this?&lt;/P&gt;&lt;P&gt;Example current data:&lt;/P&gt;&lt;P&gt;Ticker&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Fiscal Year End&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01/31/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02/28/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03/31/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 04/30/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05/31/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05/31/2000&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06/30/2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example wanted result:&lt;/P&gt;&lt;P&gt;Ticker&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Fiscal Year End&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01/31/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/31/2000&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02/28/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/31/2000&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03/31/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/31/2000&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 04/30/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/31/2000&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05/31/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/31/2000&lt;/P&gt;&lt;P&gt;APPL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06/30/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05/31/2001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2021 23:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713783#M220262</guid>
      <dc:creator>lb16fa</dc:creator>
      <dc:date>2021-01-24T23:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate missing observations with the next available observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713788#M220267</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357836"&gt;@lb16fa&lt;/a&gt;&amp;nbsp; Is your data consistent and a good representative of your real. Can I assume you just want to populate the missing values with the non missing value -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;

&amp;nbsp;create table want as

&amp;nbsp;select ticker,date, max(fiscal_year_end) as&amp;nbsp;fiscal_year_end

&amp;nbsp;from have

group by ticker

order by ticker, date;

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 00:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713788#M220267</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-25T00:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate missing observations with the next available observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713790#M220269</link>
      <description>&lt;P&gt;There is no May 31st, 200&lt;STRONG&gt;1&lt;/STRONG&gt; in your source dataset. From where do you take it?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 00:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713790#M220269</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-25T00:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate missing observations with the next available observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713809#M220285</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; thanks for the quick response! This method isn't working for me because I have multiple fiscal years of data and multiple tickers, I received an output with a table with the same fiscal year end date for each one. I found the code below. It seems to be working for me with just one issue, I can't group the variables by ticker. I'd like the code to check if the ticker is the same before populating it with the next fiscal year end date (as if it were grouped using a by statement) Any ideas on a new code or updates to this one? Thank you so much!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until(fiscal_year_end or last);
  set have end=last;
  if not missing(fiscal_year_end) then want_value=fiscal_year_end;
 end;
 do until(fiscal_year_end or _last);
  set have end=_last;
  output;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jan 2021 04:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713809#M220285</guid>
      <dc:creator>lb16fa</dc:creator>
      <dc:date>2021-01-25T04:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate missing observations with the next available observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713811#M220287</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; thank you also for the quick response! The May 31st, 2001 would come from the next fiscal year end date below it. Every date observation is empty with the exception of the one that aligns with the true fiscal year end. I mentioned this is the previous reply, but I found this code that works for me with the exception that I'm unable to group by ticker (so in several cases the newly populated "fiscal year end" is associated with a different ticker). Is there any way for this code to check that the ticker is the same, or to group by ticker? Thanks again!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until(fiscal_year_end or last);
  set have end=last;
  if not missing(fiscal_year_end) then want_value=fiscal_year_end;
 end;
 do until(fiscal_year_end or _last);
  set have end=_last;
  output;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jan 2021 04:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713811#M220287</guid>
      <dc:creator>lb16fa</dc:creator>
      <dc:date>2021-01-25T04:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate missing observations with the next available observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713845#M220301</link>
      <description>&lt;P&gt;With Proc SQL it's quite easy, just pick have -table twice:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select a.Ticker,&lt;BR /&gt;a.Date,&lt;BR /&gt;b.Fiscal_Year_End&lt;BR /&gt;from Have A&lt;BR /&gt;left join have b&lt;BR /&gt;on A.Ticker = B.Ticker&lt;BR /&gt;and B.Date ge A.Date&lt;BR /&gt;and B.Fiscal_Year_End gt .&lt;BR /&gt;group by A.Ticker, A.Date&lt;BR /&gt;having B.Fiscal_Year_End = min(B.Fiscal_Year_End);&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 08:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713845#M220301</guid>
      <dc:creator>Aku</dc:creator>
      <dc:date>2021-01-25T08:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate missing observations with the next available observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713849#M220303</link>
      <description>&lt;P&gt;This illustrates my previous question nicely. When there is no observation containing the end date for the final fiscal year of a ticker, how do you get it?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 12:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713849#M220303</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-25T12:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate missing observations with the next available observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713875#M220311</link>
      <description>data want;&lt;BR /&gt; merge have have(keep=ticker fiscal_year_end  where=(fiscal_year_end is not missing));&lt;BR /&gt;by ticker;&lt;BR /&gt;run;</description>
      <pubDate>Mon, 25 Jan 2021 11:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/713875#M220311</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-25T11:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate missing observations with the next available observation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/714119#M220412</link>
      <description>This works for me! Thanks so much.</description>
      <pubDate>Mon, 25 Jan 2021 22:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-missing-observations-with-the-next-available/m-p/714119#M220412</guid>
      <dc:creator>lb16fa</dc:creator>
      <dc:date>2021-01-25T22:59:28Z</dc:date>
    </item>
  </channel>
</rss>

