<?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 Repeat Values For Unique ID With Exceptions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Repeat-Values-For-Unique-ID-With-Exceptions/m-p/894708#M353425</link>
    <description>&lt;P&gt;I have a column with IDs that repeat, and I would like to translate the second column to repeat the first value for each unique ID. EXCEPT for when the value is NULL, the value needs to stay NULL. Below is an example of the column I have, and the column I want.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;&lt;STRONG&gt;ID  HAVE  WANT
1   12    12
1   19    12
1   23    12
2   40    40
2   NULL  NULL&lt;BR /&gt;2   25    40&lt;BR /&gt;3   NULL  NULL&lt;BR /&gt;3   11    11&lt;BR /&gt;3   NULL  NULL&lt;BR /&gt;4   24    24&lt;BR /&gt;4   NULL  NULL&lt;BR /&gt;4   72    24&lt;BR /&gt;4   NULL  NULL&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 17 Sep 2023 21:06:20 GMT</pubDate>
    <dc:creator>chsprogramming</dc:creator>
    <dc:date>2023-09-17T21:06:20Z</dc:date>
    <item>
      <title>Repeat Values For Unique ID With Exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeat-Values-For-Unique-ID-With-Exceptions/m-p/894708#M353425</link>
      <description>&lt;P&gt;I have a column with IDs that repeat, and I would like to translate the second column to repeat the first value for each unique ID. EXCEPT for when the value is NULL, the value needs to stay NULL. Below is an example of the column I have, and the column I want.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;&lt;STRONG&gt;ID  HAVE  WANT
1   12    12
1   19    12
1   23    12
2   40    40
2   NULL  NULL&lt;BR /&gt;2   25    40&lt;BR /&gt;3   NULL  NULL&lt;BR /&gt;3   11    11&lt;BR /&gt;3   NULL  NULL&lt;BR /&gt;4   24    24&lt;BR /&gt;4   NULL  NULL&lt;BR /&gt;4   72    24&lt;BR /&gt;4   NULL  NULL&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Sep 2023 21:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeat-Values-For-Unique-ID-With-Exceptions/m-p/894708#M353425</guid>
      <dc:creator>chsprogramming</dc:creator>
      <dc:date>2023-09-17T21:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat Values For Unique ID With Exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeat-Values-For-Unique-ID-With-Exceptions/m-p/894722#M353431</link>
      <description>&lt;P&gt;Something like below should do.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id have want;
  datalines;
1 12 12
1 19 12
1 23 12
2 40 40
2 . .
2 25 40
3 . .
3 11 11
3 . .
4 24 24
4 . .
4 72 24
4 . .
;

data want(drop=_:);
  set have;
  by id;
  retain _tmp;
  if first.id then call missing(_tmp);
  if not missing(have) then
    do;
      if missing(_tmp) then _tmp=have;
      derived=_tmp;
    end;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Sep 2023 00:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeat-Values-For-Unique-ID-With-Exceptions/m-p/894722#M353431</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-09-18T00:32:33Z</dc:date>
    </item>
  </channel>
</rss>

