<?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: Data step set or merge question involving lags in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568807#M160203</link>
    <description>&lt;P&gt;Here's something to consider.&amp;nbsp; It assumes there are no more than 999 numeric variables, no more than 999 character variables, and a maximum length for any character variable of $1000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if 5=4 then do;
   set left (drop=id year) right (drop=id year);
   array nums {*} _numeric_;
   array chars {*} _character_;
   array priorn {999} _temporary_;
   array prilorc {999} $1000 _temporary_;
end;
set left right;
by id date;
do _n_=1 to dim(nums);
   priorn{_n_} = lag(nums{_n_});
   if nums{_n_} = . then nums{_n_} = priorn{_n_};
end;
do _n_=1 to dim(chars);
   priorc{_n_} = lag(chars{_n_});
   if chars{_n_} = " " then chars{_n_} = priorc{_n_};
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's long, it's somewhat clumsy, and it's untested.&amp;nbsp; Perhaps it's useful nevertheless.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jun 2019 14:56:37 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-06-25T14:56:37Z</dc:date>
    <item>
      <title>Data step set, merge or update question involving lags or retains</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568750#M160175</link>
      <description>&lt;P&gt;Is there a way to use merge, modify, update or set to do the following&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Left (sortedby=ID date);
  infile datalines;
  input ID $4.  RDATE  MMDDYY12. date MMDDYY10.;
    format RDATE date mmddyy10.;
datalines;
A998 06/01/2018 06/01/2018  
B027 05/21/2018 05/21/2018  
C001 03/31/2018 03/31/2018  
D221 11/01/2017 11/01/2017  
E379 10/07/2017 10/07/2017  
F693 06/19/2018 06/19/2018  
;
run;

data Right (sortedby=ID date);
  infile datalines;
  input ID $4.	INTVDT MMDDYY12.	STA  $1.	date MMDDYY11.;
    format INTVDT date mmddyy10.;
datalines;
A998 09/30/2012 Z 09/30/2012  
A998 03/11/2013 Y 03/11/2013  
A998 07/31/2017 X 07/31/2017  
A998 02/21/2018 W 02/21/2018  
B027 05/17/2011 V 05/17/2011  
E379 10/04/2017 U 10/04/2017  
G032 03/01/2017 T 03/01/2017   
;
run;

data whole;
  set left Right;
  by ID date;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the desired dataset.&amp;nbsp; Where the bolded data are lagged, retained or it is as if the SET statement forgot to clear the data vector each record.&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;ID   RDATE    date     INTVDT   STA&lt;BR /&gt;&lt;/STRONG&gt;A998 .        09/30/12 09/30/12 Z
A998 .        03/11/13 03/11/13 Y
A998 .        07/31/17 07/31/17 X
A998 .        02/21/18 02/21/18 W
A998 06/01/18 06/01/18 &lt;STRONG&gt;02/21/18 W&lt;BR /&gt;&lt;/STRONG&gt;B027 &lt;STRONG&gt;06/01/18&lt;/STRONG&gt; 05/17/11 05/17/11 V
B027 05/21/18 05/21/18 &lt;STRONG&gt;05/17/11 V&lt;/STRONG&gt;
C001 03/31/18 03/31/18 &lt;STRONG&gt;05/17/11 V&lt;/STRONG&gt;
D221 11/01/17 11/01/17 &lt;STRONG&gt;05/17/11 V&lt;/STRONG&gt;
E379 &lt;STRONG&gt;11/01/17&lt;/STRONG&gt; 10/04/17 10/04/17 U
E379 10/07/17 10/07/17 &lt;STRONG&gt;10/04/17 U&lt;BR /&gt;&lt;/STRONG&gt;F693 06/19/18 06/19/18 &lt;STRONG&gt;10/04/17 U&lt;BR /&gt;&lt;/STRONG&gt;G032 &lt;STRONG&gt;06/19/18&lt;/STRONG&gt; 03/01/17 03/01/17 T&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Instead of this, as coded:&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;ID   RDATE    date     INTVDT   STA&lt;BR /&gt;&lt;/STRONG&gt;A998 .        09/30/12 09/30/12 Z
A998 .        03/11/13 03/11/13 Y
A998 .        07/31/17 07/31/17 X
A998 .        02/21/18 02/21/18 W
A998 06/01/18 06/01/18 . 
B027 .        05/17/11 05/17/11 V
B027 05/21/18 05/21/18 . 
C001 03/31/18 03/31/18 . 
D221 11/01/17 11/01/17 . 
E379 .        10/04/17 10/04/17 U
E379 10/07/17 10/07/17 . 
F693 06/19/18 06/19/18 . 
G032 .        03/01/17 03/01/17 T&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jun 2019 18:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568750#M160175</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2019-06-26T18:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568758#M160178</link>
      <description>&lt;P&gt;This looks about right:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data whole;
   set left right;
   by id date;
   prior_rdate = lag(rdate);
   prior_intvdt = lag(intvdt);
   prior_sta = lag(sta);
   if rdate = . then rdate = prior_rdate;
   if intvdt = . then intvdt = prior_intvdt;
   if sta = ' ' then sta = prior_sta;
   drop prior_: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Give it a test and see if it does what you need.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 13:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568758#M160178</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-25T13:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568773#M160183</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Pro:&lt;/STRONG&gt;&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;it works.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;&lt;STRONG&gt;Kuddos:&lt;/STRONG&gt; &lt;SPAN class="token keyword" style="background-attachment: scroll; background-clip: border-box; background-color: #ffffff; background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; color: #0000ff; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 16.8px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #000000; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; -ms-hyphens: none; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: 0px; word-wrap: normal;"&gt; prior_: &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Con:&lt;/STRONG&gt; To scale this up, we'd need a lag() function, if statement and &lt;STRONG&gt;prior_&lt;/STRONG&gt; variable for each column not in the by statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for something else.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568773#M160183</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2019-06-25T14:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568777#M160186</link>
      <description>&lt;P&gt;I always do some of my best thinking after I've asked smart people for help.&amp;nbsp; I came up with this after asking.&amp;nbsp; Adding indexes to the two input files one can do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data whole2;
  set Left  (keep=ID date)
      Right (keep=ID date);
  by ID date;
  set Left  key=IDdate;
  set Right key=IDdate;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Con&lt;/STRONG&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;: extra SET KEY statement for each file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;&lt;STRONG&gt;Con&lt;/STRONG&gt;: possible file errors&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;&lt;STRONG&gt;Annoyances&lt;/STRONG&gt;: Keep statements and indexes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone one-up me here?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568777#M160186</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2019-06-25T14:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568780#M160188</link>
      <description>&lt;P&gt;There are several ways to go.&amp;nbsp; You could use macro language to generate as many "prior" variables as needed.&amp;nbsp; But there are issues that require knowing something about your data.&amp;nbsp; These would be helpful questions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Do you know how many numeric variables you have?&lt;/LI&gt;
&lt;LI&gt;Do you know how many character variables you have?&lt;/LI&gt;
&lt;LI&gt;Will the BY variables always be the same?&lt;/LI&gt;
&lt;LI&gt;For character variables, do you know the maximum length across all character variables?&lt;/LI&gt;
&lt;LI&gt;What is the maximum length for variable names (so that we know there would be room to prefix them with "prior_")?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The answers can guide the proper approach.&amp;nbsp; Approximate answers are probably OK.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568780#M160188</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-25T14:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568790#M160191</link>
      <description>&lt;P&gt;This is a common thing that I want to do.&amp;nbsp; Each time I encounter it, I feel like I have to re-engineer the solution.&amp;nbsp; Last time I asked this question I was educated about set statement interleaving, this blew my mind since I never encountered this even after seven years of SAS experience. &amp;nbsp; I'm wondering if there is something else to learn...&amp;nbsp; but if not, then maybe this is a simple enough thing to ask for a new option in the set statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Edit:&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN style="text-align: left; color: #333333; text-transform: none; line-height: 20px; text-indent: 0px; letter-spacing: normal; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-variant: normal; font-weight: 400; text-decoration: none; word-spacing: 0px; display: inline !important; white-space: normal; visibility: visible; word-wrap: break-word; orphans: 2; float: none; -webkit-text-stroke-width: 0px; background-color: transparent;"&gt;ok, that was &lt;STRONG&gt;you&lt;/STRONG&gt; that showed me the set statement interleave. ha ha &lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568790#M160191</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2019-06-25T14:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568803#M160199</link>
      <description>&lt;P&gt;Does this solution actually work when you cross the boundary from one ID to the next?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568803#M160199</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-25T14:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568805#M160201</link>
      <description>&lt;P&gt;A Do Whitlock loop and a call missing function would handle that.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568805#M160201</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2019-06-25T14:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568807#M160203</link>
      <description>&lt;P&gt;Here's something to consider.&amp;nbsp; It assumes there are no more than 999 numeric variables, no more than 999 character variables, and a maximum length for any character variable of $1000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if 5=4 then do;
   set left (drop=id year) right (drop=id year);
   array nums {*} _numeric_;
   array chars {*} _character_;
   array priorn {999} _temporary_;
   array prilorc {999} $1000 _temporary_;
end;
set left right;
by id date;
do _n_=1 to dim(nums);
   priorn{_n_} = lag(nums{_n_});
   if nums{_n_} = . then nums{_n_} = priorn{_n_};
end;
do _n_=1 to dim(chars);
   priorc{_n_} = lag(chars{_n_});
   if chars{_n_} = " " then chars{_n_} = priorc{_n_};
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's long, it's somewhat clumsy, and it's untested.&amp;nbsp; Perhaps it's useful nevertheless.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568807#M160203</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-25T14:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568809#M160204</link>
      <description>&lt;P&gt;That's so great, to me, -- my coworkers, OTOH, would hate me if I coded like that.&lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://communities.sas.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Honestly,&amp;nbsp; I want this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data whole;
  set left Right /noPDVreset;
  by ID date;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks for your contribution,&amp;nbsp; also thanks for teaching me about SET statement, way back, too.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 15:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568809#M160204</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2019-06-25T15:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568876#M160231</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15329"&gt;@PhilC&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe the "UPDATE trick" (which I've learned in this forum) can help a bit:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tmp / view=tmp;
set left Right;
by ID date;
_i=.;
run;

data whole(drop=_i);
update tmp(obs=0) tmp;
by _i;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jun 2019 17:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568876#M160231</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-06-25T17:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Data step set or merge question involving lags</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568895#M160240</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Pro&lt;/STRONG&gt;: it works&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Pro&lt;/STRONG&gt;: This works if you want to respect the ID boundaries.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tmp0 tmp1 ;
  do until (last.ID); 
    set left Right; by ID date; output tmp1;
  end;
  output tmp0;
data whole3;
  update tmp0 tmp1; by ID; output; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Annoyance&lt;/STRONG&gt;s&lt;STRONG&gt;:&lt;/STRONG&gt; opening a file twice, a little too many lines...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this just the "Update trick" it needs another name.&amp;nbsp; &lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Thanks&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;edit&lt;/STRONG&gt;: The "&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12262" target="_self"&gt;KMW&lt;/A&gt;-update trick"?&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-can-I-combine-multiple-rows-to-a-single-row/td-p/16151" target="_self"&gt;SAS-Programming/How-can-I-combine-multiple-rows-to-a-single-row&lt;/A&gt;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12262"&gt;@kmw&lt;/a&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 20:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-set-merge-or-update-question-involving-lags-or-retains/m-p/568895#M160240</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2019-06-25T20:09:05Z</dc:date>
    </item>
  </channel>
</rss>

