<?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: filling in missing values with respect to the values of another variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/806676#M317866</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;.&amp;nbsp; Thank you for the reply.&amp;nbsp; Here is the code I used to generate the subset of PROC PRINT shown below.&amp;nbsp; But what I want is the ihdi value at obs=8 to fill in obs=9 and 10, the last year for ctryno=1.&amp;nbsp; I also want ihdi=0.311 at obs=21 to fill in obs=22.&amp;nbsp; Similarly throughout the data file.&amp;nbsp; Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data want;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;retain country code year ctryno;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;set have;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;by ctryno year;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;retain _ihdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if first.code then call missing(_ihdi);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if not missing(ihdi) then _ihdi=ihdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;else ihdi=_ihdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;drop _ihdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;proc print data=want;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var code ctryno year ihdi hdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bherrin_0-1649372773029.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70229i01269EF064828F73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bherrin_0-1649372773029.png" alt="bherrin_0-1649372773029.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Apr 2022 23:10:32 GMT</pubDate>
    <dc:creator>bherrin</dc:creator>
    <dc:date>2022-04-07T23:10:32Z</dc:date>
    <item>
      <title>filling in missing values with respect to the values of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/706724#M216933</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am adding a picture to illustrate my question - I have many different ISIN values, dates and ExecPrices. My question is, when it is sorted out by ISIN and DATE, how can I fill in the missing values of ExecPrice with the previous values of ExecPrice only and only if the dates are concerning the same ISIN value? For example in the attached picture, I would want the empty spaces of ExecPrice to be filled with the previous value. But I want it to be filled only because ISIN value is the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to use another solution to the missing value problem suggested in this forum but this way of filling in the blank spaces does not stop if the ISIN number changes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;retain _ExecPrice;&lt;BR /&gt;if not missing(ExecPrice) then _ExecPrice=ExecPrice;&lt;BR /&gt;else ExecPrice=_ExecPrice;&lt;BR /&gt;drop _ExecPrice;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot (35).png" style="width: 455px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52764iE84B9678BAFDCC72/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (35).png" alt="Screenshot (35).png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 17:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/706724#M216933</guid>
      <dc:creator>aiste</dc:creator>
      <dc:date>2020-12-17T17:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: filling in missing values with respect to the values of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/706739#M216940</link>
      <description>&lt;P&gt;You need to do BY GROUP processing-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
set have;
by isin date;
retain _ExecPrice;
if first.date then call missing(_ExecPrice);
if not missing(ExecPrice) then _ExecPrice=ExecPrice;
else ExecPrice=_ExecPrice;
drop _ExecPrice;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Dec 2020 18:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/706739#M216940</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-12-17T18:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: filling in missing values with respect to the values of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/706740#M216941</link>
      <description>&lt;P&gt;Alternatively, you could use UPDATE instead of RETAIN gymnastics-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 update have(obs=0) have;
 by isin date;
 output;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Dec 2020 18:32:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/706740#M216941</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-12-17T18:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: filling in missing values with respect to the values of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/717825#M222056</link>
      <description>thank you, that worked!</description>
      <pubDate>Tue, 09 Feb 2021 09:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/717825#M222056</guid>
      <dc:creator>aiste</dc:creator>
      <dc:date>2021-02-09T09:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: filling in missing values with respect to the values of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/806178#M317594</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a similar problem to the one 'aiste' posted.&amp;nbsp; I tried following the code that worked for them, but it doesn't do what I want.&amp;nbsp; Below is a print of the 27 obs.&amp;nbsp; 'Code' and 'ctryno' identify countries.&amp;nbsp; I want to fill in missing values for 'ihdi' with the previous one but only for the same value of 'code'.&amp;nbsp; I understand that this can't be done for first.code (which is year 2010) if that value is missing, but Given the 2010 value of 'Ango', I want the 2011 value to be the same.&amp;nbsp; Same for 2011-2013 for "Beli'.&amp;nbsp; Here is my last code attempt.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;data four; set three;&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;by ctryno year;&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;retain _ihdi;&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;if first.ctryno then call missing(_ihdi);&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;if not missing(ihdi) then _ihdi=ihdi;&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;else ihdi=_ihdi;&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bherrin_0-1649204792978.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70144i677FDBCA49FC2F04/image-size/large?v=v2&amp;amp;px=999" role="button" title="bherrin_0-1649204792978.png" alt="bherrin_0-1649204792978.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 00:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/806178#M317594</guid>
      <dc:creator>bherrin</dc:creator>
      <dc:date>2022-04-06T00:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: filling in missing values with respect to the values of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/806295#M317641</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/306720"&gt;@bherrin&lt;/a&gt;&amp;nbsp; Thank you for reaching out. Could you please post a sample data of what you "HAVE" that I can copy/paste to my SAS/SQL client and the expected "OUTPUT(WANT)" for me to work with. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 14:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/806295#M317641</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2022-04-06T14:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: filling in missing values with respect to the values of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/806676#M317866</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;.&amp;nbsp; Thank you for the reply.&amp;nbsp; Here is the code I used to generate the subset of PROC PRINT shown below.&amp;nbsp; But what I want is the ihdi value at obs=8 to fill in obs=9 and 10, the last year for ctryno=1.&amp;nbsp; I also want ihdi=0.311 at obs=21 to fill in obs=22.&amp;nbsp; Similarly throughout the data file.&amp;nbsp; Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data want;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;retain country code year ctryno;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;set have;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;by ctryno year;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;retain _ihdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if first.code then call missing(_ihdi);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if not missing(ihdi) then _ihdi=ihdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;else ihdi=_ihdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;drop _ihdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;proc print data=want;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var code ctryno year ihdi hdi;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bherrin_0-1649372773029.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70229i01269EF064828F73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bherrin_0-1649372773029.png" alt="bherrin_0-1649372773029.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 23:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filling-in-missing-values-with-respect-to-the-values-of-another/m-p/806676#M317866</guid>
      <dc:creator>bherrin</dc:creator>
      <dc:date>2022-04-07T23:10:32Z</dc:date>
    </item>
  </channel>
</rss>

