<?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 How to create a baseline value with missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781047#M248917</link>
    <description>&lt;P&gt;Hi all,&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have data where in some records visit 1 is missing, meaning I need SAS to set the baseline value to the first observation that has an actual value. Here is my data +code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; WORK.test;

&lt;FONT color="#0000FF"&gt;input&lt;/FONT&gt; record visit orange apple;
&lt;FONT color="#0000FF"&gt;CARDS&lt;/FONT&gt;;
1 1  1 .        
1 2  1 1
1 3  1 1
1 4  0 1
1 5  0 3
1 6  0 0 
1 7  0 0
2 1  2 .
2 2  0 .
2 3  0 1
2 4  0 0
;
&lt;FONT color="#0000FF"&gt;run&lt;/FONT&gt;;
 &lt;BR /&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; test2;

 &lt;FONT color="#0000FF"&gt;set&lt;/FONT&gt; test;

&lt;FONT color="#0000FF"&gt; by&lt;/FONT&gt; record visit;
 

&lt;FONT color="#0000FF"&gt; retain&lt;/FONT&gt; baseline_apple;
 

&lt;FONT color="#0000FF"&gt;if&lt;/FONT&gt; (first.record) and apple ne . then  baseline_apple=apple; &lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I run this, it only sets baseline when the value isn't missing which is good, but I can't figure out how to tell it to use the next observation (if also not missing ) as the baseline and retain that baseline value for the rest of the visits.&amp;nbsp; (baseline gets set for each record ).&lt;/P&gt;
&lt;P&gt;output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="schatr2_0-1637250407740.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65874i57AE748D9943BF0B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="schatr2_0-1637250407740.png" alt="schatr2_0-1637250407740.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;What I want is this:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;record&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;visit&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;apple&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;baseline&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;4&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;5&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;if I use "else baseline=apple" it won't retain the value across visits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I dont wan't to use a statement like where apple ne . because it will delete the entire row and I could lose data for other variables in my data set.&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;</description>
    <pubDate>Thu, 18 Nov 2021 16:00:53 GMT</pubDate>
    <dc:creator>393310</dc:creator>
    <dc:date>2021-11-18T16:00:53Z</dc:date>
    <item>
      <title>How to create a baseline value with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781047#M248917</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have data where in some records visit 1 is missing, meaning I need SAS to set the baseline value to the first observation that has an actual value. Here is my data +code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; WORK.test;

&lt;FONT color="#0000FF"&gt;input&lt;/FONT&gt; record visit orange apple;
&lt;FONT color="#0000FF"&gt;CARDS&lt;/FONT&gt;;
1 1  1 .        
1 2  1 1
1 3  1 1
1 4  0 1
1 5  0 3
1 6  0 0 
1 7  0 0
2 1  2 .
2 2  0 .
2 3  0 1
2 4  0 0
;
&lt;FONT color="#0000FF"&gt;run&lt;/FONT&gt;;
 &lt;BR /&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; test2;

 &lt;FONT color="#0000FF"&gt;set&lt;/FONT&gt; test;

&lt;FONT color="#0000FF"&gt; by&lt;/FONT&gt; record visit;
 

&lt;FONT color="#0000FF"&gt; retain&lt;/FONT&gt; baseline_apple;
 

&lt;FONT color="#0000FF"&gt;if&lt;/FONT&gt; (first.record) and apple ne . then  baseline_apple=apple; &lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I run this, it only sets baseline when the value isn't missing which is good, but I can't figure out how to tell it to use the next observation (if also not missing ) as the baseline and retain that baseline value for the rest of the visits.&amp;nbsp; (baseline gets set for each record ).&lt;/P&gt;
&lt;P&gt;output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="schatr2_0-1637250407740.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65874i57AE748D9943BF0B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="schatr2_0-1637250407740.png" alt="schatr2_0-1637250407740.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;What I want is this:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;record&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;visit&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;apple&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;baseline&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;4&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;5&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;if I use "else baseline=apple" it won't retain the value across visits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I dont wan't to use a statement like where apple ne . because it will delete the entire row and I could lose data for other variables in my data set.&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 16:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781047#M248917</guid>
      <dc:creator>393310</dc:creator>
      <dc:date>2021-11-18T16:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a baseline value with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781056#M248918</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data test2;

 set test;

 by record visit;
 
 retain baseline_apple;
 
if first.record then call missing(baseline_apple);

if missing(baseline_apple) then baseline_apple = apple;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I dont wan't to use a statement like where apple ne . because it will delete the entire row and I could lose data for other variables in my data set.&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you're referring to a subsetting IF? You can control the behaviour on the condition so it does not delete rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393310"&gt;@393310&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have data where in some records visit 1 is missing, meaning I need SAS to set the baseline value to the first observation that has an actual value. Here is my data +code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; WORK.test;

&lt;FONT color="#0000FF"&gt;input&lt;/FONT&gt; record visit orange apple;
&lt;FONT color="#0000FF"&gt;CARDS&lt;/FONT&gt;;
1 1  1 .        
1 2  1 1
1 3  1 1
1 4  0 1
1 5  0 3
1 6  0 0 
1 7  0 0
2 1  2 .
2 2  0 .
2 3  0 1
2 4  0 0
;
&lt;FONT color="#0000FF"&gt;run&lt;/FONT&gt;;
 &lt;BR /&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; test2;

 &lt;FONT color="#0000FF"&gt;set&lt;/FONT&gt; test;

&lt;FONT color="#0000FF"&gt; by&lt;/FONT&gt; record visit;
 

&lt;FONT color="#0000FF"&gt; retain&lt;/FONT&gt; baseline_apple;
 

&lt;FONT color="#0000FF"&gt;if&lt;/FONT&gt; (first.record) and apple ne . then  baseline_apple=apple; &lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I run this, it only sets baseline when the value isn't missing which is good, but I can't figure out how to tell it to use the next observation (if also not missing ) as the baseline and retain that baseline value for the rest of the visits.&amp;nbsp; (baseline gets set for each record ).&lt;/P&gt;
&lt;P&gt;output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="schatr2_0-1637250407740.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65874i57AE748D9943BF0B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="schatr2_0-1637250407740.png" alt="schatr2_0-1637250407740.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;What I want is this:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;record&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;visit&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;apple&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;baseline&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;4&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;5&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;if I use "else baseline=apple" it won't retain the value across visits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I dont wan't to use a statement like where apple ne . because it will delete the entire row and I could lose data for other variables in my data set.&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 16:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781056#M248918</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-18T16:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a baseline value with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781069#M248920</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That almost works except it does not retain the baseline across the rest of the visits. Any idea how I could get it to retain?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output with your code:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="schatr2_1-1637255009175.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65878iBDE4BBCBE3552460/image-size/medium?v=v2&amp;amp;px=400" role="button" title="schatr2_1-1637255009175.png" alt="schatr2_1-1637255009175.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 17:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781069#M248920</guid>
      <dc:creator>393310</dc:creator>
      <dc:date>2021-11-18T17:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a baseline value with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781071#M248921</link>
      <description>&lt;P&gt;Please show your code - that seems like the result without a RETAIN statement.&amp;nbsp;&lt;BR /&gt;Note that if you have baseline already in your data set and it's not a new variable you may also see this type of behaviour.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you use your sample data and the code provided it seems to generate the exact results expected, is that correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards dlm='09'x dsd truncover;
input record	visit	apple	baseline;
cards;
1	1	.	.
1	2	1	1
1	3	1	1
1	4	1	1
1	5	3	1
2	1	.	.
2	2	.	.
2	3	1	1
;;;
run;


data want;
set have;
by record visit;
retain baseline_apple;
if first.record then call missing(baseline_apple);

if missing(baseline_apple) then baseline_apple = apple;

run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393310"&gt;@393310&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That almost works except it does not retain the baseline across the rest of the visits. Any idea how I could get it to retain?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output with your code:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="schatr2_1-1637255009175.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65878iBDE4BBCBE3552460/image-size/medium?v=v2&amp;amp;px=400" role="button" title="schatr2_1-1637255009175.png" alt="schatr2_1-1637255009175.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 17:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781071#M248921</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-18T17:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a baseline value with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781075#M248922</link>
      <description>Sorry I must've left something out. I re ran again and it retained. Thank you so much!</description>
      <pubDate>Thu, 18 Nov 2021 17:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-baseline-value-with-missing-values/m-p/781075#M248922</guid>
      <dc:creator>393310</dc:creator>
      <dc:date>2021-11-18T17:25:45Z</dc:date>
    </item>
  </channel>
</rss>

