<?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 fill missing value base on another col and the last row value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-missing-value-base-on-another-col-and-the-last-row/m-p/898631#M355204</link>
    <description>It looks like this method will change current order 2&amp;amp; 3 to 2, and only have 6 instead 7. Any way to solve this?</description>
    <pubDate>Sun, 15 Oct 2023 01:03:53 GMT</pubDate>
    <dc:creator>stataq</dc:creator>
    <dc:date>2023-10-15T01:03:53Z</dc:date>
    <item>
      <title>How to fill missing value base on another col and the last row value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-missing-value-base-on-another-col-and-the-last-row/m-p/898625#M355200</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I would like to get the table on right hand side, from a table that is on the left hand side:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="stataq_0-1697323489687.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88865iB61F54F3E796ED64/image-size/medium?v=v2&amp;amp;px=400" role="button" title="stataq_0-1697323489687.png" alt="stataq_0-1697323489687.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Basically, I want when `order`=.,&amp;nbsp; and then by `ID`, `order` will be last `order`+1. The red number will be the number I want.&lt;/P&gt;&lt;P&gt;What should I do in order to get such result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2023 22:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-missing-value-base-on-another-col-and-the-last-row/m-p/898625#M355200</guid>
      <dc:creator>stataq</dc:creator>
      <dc:date>2023-10-14T22:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill missing value base on another col and the last row value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-missing-value-base-on-another-col-and-the-last-row/m-p/898628#M355201</link>
      <description>&lt;P&gt;Please provide sample data via a SAS data step that creates the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the Have data you shared is representative for your real data then below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have(drop=order);
  by id notsorted;
  if first.id then order+1;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2023 23:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-missing-value-base-on-another-col-and-the-last-row/m-p/898628#M355201</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-14T23:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill missing value base on another col and the last row value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-missing-value-base-on-another-col-and-the-last-row/m-p/898631#M355204</link>
      <description>It looks like this method will change current order 2&amp;amp; 3 to 2, and only have 6 instead 7. Any way to solve this?</description>
      <pubDate>Sun, 15 Oct 2023 01:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-missing-value-base-on-another-col-and-the-last-row/m-p/898631#M355204</guid>
      <dc:creator>stataq</dc:creator>
      <dc:date>2023-10-15T01:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill missing value base on another col and the last row value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-missing-value-base-on-another-col-and-the-last-row/m-p/898632#M355205</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/448857"&gt;@stataq&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;It looks like this method will change current order 2&amp;amp; 3 to 2, and only have 6 instead 7. Any way to solve this?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's why you should provide sample data via a SAS datastep so we can actually test the code we propose.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dsd dlm=',' truncover;
  input id $ order order_want;
  datalines;
B1,,1
B1,,1
,2,2
,2,2
,3,3
,3,3
,3,3
C1,,4
C1,,4
C1,,4
C3,,5
C3,,5
,6,6
,6,6
D4,,7
D4,,7
;
data want;
  set have(rename=(order=order_have));
  by id notsorted;
  if not missing(order_have) then order_derived=order_have;
  else if first.id then order_derived+1;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Oct 2023 01:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-missing-value-base-on-another-col-and-the-last-row/m-p/898632#M355205</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-15T01:27:56Z</dc:date>
    </item>
  </channel>
</rss>

