<?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: Replace missing in a by group context in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-in-a-by-group-context/m-p/724587#M224961</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;

input ID visit_no result $;

datalines;

1 1 positive

1 2 .

1 3 .

1 4 positive

2 1 negative

2 2 negative

2 3 positive

2 4 .

2 5 .

3 1 .

3 2 negative

3 3 .

4 1 .

4 2 positive

;

run;

data want;
 set have;
 by id;
 retain t;
 length t $20;
 if first.id then t=' ';
 if not missing(result) then t=result;
 else if t='positive' then result=t;
 drop t;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Mar 2021 18:30:24 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2021-03-08T18:30:24Z</dc:date>
    <item>
      <title>Replace missing in a by group context</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-in-a-by-group-context/m-p/724582#M224958</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have attached here the code to the dataset that I have and what I am trying to get to but have some difficulty. Essentially, I have a dataset with multiple visits (visit_no) by ID (different IDs have different number of total visits). For each ID, I am trying to fill in the missing values for "result" as "positive" for all visits following a visit in which this variable was already recorded as being "positive". Note: only looking forward when replacing the missing as positive. Note2: if result is negative, leave missing as is. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks in advance for your help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; have;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;input&lt;/SPAN&gt; ID visit_no result $;&lt;/P&gt;
&lt;P&gt;datalines&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 1 positive&lt;/P&gt;
&lt;P&gt;1 2 .&lt;/P&gt;
&lt;P&gt;1 3 .&lt;/P&gt;
&lt;P&gt;1 4 positive&lt;/P&gt;
&lt;P&gt;2 1 negative&lt;/P&gt;
&lt;P&gt;2 2 negative&lt;/P&gt;
&lt;P&gt;2 3 positive&lt;/P&gt;
&lt;P&gt;2 4 .&lt;/P&gt;
&lt;P&gt;2 5 .&lt;/P&gt;
&lt;P&gt;3 1 .&lt;/P&gt;
&lt;P&gt;3 2 negative&lt;/P&gt;
&lt;P&gt;3 3 .&lt;/P&gt;
&lt;P&gt;4 1 .&lt;/P&gt;
&lt;P&gt;4 2 positive&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;input&lt;/SPAN&gt; ID visit_no result $;&lt;/P&gt;
&lt;P&gt;datalines&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1 1 positive&lt;/P&gt;
&lt;P&gt;1 2 positive&lt;/P&gt;
&lt;P&gt;1 3 positive&lt;/P&gt;
&lt;P&gt;1 4 positive&lt;/P&gt;
&lt;P&gt;2 1 negative&lt;/P&gt;
&lt;P&gt;2 2 negative&lt;/P&gt;
&lt;P&gt;2 3 positive&lt;/P&gt;
&lt;P&gt;2 4 positive&lt;/P&gt;
&lt;P&gt;2 5 positive&lt;/P&gt;
&lt;P&gt;3 1 .&lt;/P&gt;
&lt;P&gt;3 2 negative&lt;/P&gt;
&lt;P&gt;3 3 .&lt;/P&gt;
&lt;P&gt;4 1 .&lt;/P&gt;
&lt;P&gt;4 2 positive&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 18:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-in-a-by-group-context/m-p/724582#M224958</guid>
      <dc:creator>blackandwhite</dc:creator>
      <dc:date>2021-03-08T18:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing in a by group context</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-in-a-by-group-context/m-p/724587#M224961</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;

input ID visit_no result $;

datalines;

1 1 positive

1 2 .

1 3 .

1 4 positive

2 1 negative

2 2 negative

2 3 positive

2 4 .

2 5 .

3 1 .

3 2 negative

3 3 .

4 1 .

4 2 positive

;

run;

data want;
 set have;
 by id;
 retain t;
 length t $20;
 if first.id then t=' ';
 if not missing(result) then t=result;
 else if t='positive' then result=t;
 drop t;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Mar 2021 18:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-in-a-by-group-context/m-p/724587#M224961</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-03-08T18:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing in a by group context</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-in-a-by-group-context/m-p/724589#M224963</link>
      <description>thanks so much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;</description>
      <pubDate>Mon, 08 Mar 2021 18:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-in-a-by-group-context/m-p/724589#M224963</guid>
      <dc:creator>blackandwhite</dc:creator>
      <dc:date>2021-03-08T18:34:59Z</dc:date>
    </item>
  </channel>
</rss>

