<?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: Lag function in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519139#M3733</link>
    <description>&lt;P&gt;It is showing no result.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Dec 2018 14:48:32 GMT</pubDate>
    <dc:creator>Sunnykapoor</dc:creator>
    <dc:date>2018-12-06T14:48:32Z</dc:date>
    <item>
      <title>Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519110#M3721</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on data which have several values and I have to compare them.&amp;nbsp;I am trying to use Lag function but unable to get through.&amp;nbsp;Below are the context of data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;MN&lt;/TD&gt;&lt;TD&gt;TN&lt;/TD&gt;&lt;TD&gt;EII&lt;/TD&gt;&lt;TD&gt;ND&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;238552&lt;/TD&gt;&lt;TD&gt;40006248&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;316969&lt;/TD&gt;&lt;TD&gt;40006248&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;631788&lt;/TD&gt;&lt;TD&gt;40006248&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;660798&lt;/TD&gt;&lt;TD&gt;50098722&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;660007&lt;/TD&gt;&lt;TD&gt;50098722&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;661359&lt;/TD&gt;&lt;TD&gt;50098722&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TN is the unique value and scenarios are:&lt;/P&gt;&lt;P&gt;1) we have to select TN with EII and ND as 1 and 1 only if TN with same number is followed by either EII and ND as 0 and 0 or EII and ND as 1 and 0.&lt;/P&gt;&lt;P&gt;2) No Duplicate entries for TN.&lt;/P&gt;&lt;P&gt;Please suggest&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 13:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519110#M3721</guid>
      <dc:creator>Sunnykapoor</dc:creator>
      <dc:date>2018-12-06T13:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519116#M3723</link>
      <description>&lt;P&gt;The trick when using LAG is to make sure it executes on every observation.&amp;nbsp; For example, your DATA step might contain:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;prior_ND = lag(ND);&lt;/P&gt;
&lt;P&gt;prior_EII = lag(EII);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then refer to prior_ND and prior_EII in your programming logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't fix things for you, try posting the log from your DATA step so we can see what you are attempting and why it doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also might need to describe the problem further:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Does "follow" mean on the very next observation, or on any subsequent observation?&lt;/LI&gt;
&lt;LI&gt;Could the observation with ND=1 and EII=1 be the second (or later) observation for a TN?&lt;/LI&gt;
&lt;LI&gt;How many observations might there be (maximum) for a TN?&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 06 Dec 2018 13:54:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519116#M3723</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-06T13:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519121#M3724</link>
      <description>&lt;P&gt;I have sorted the data for better understanding.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Does "follow" mean on the very next observation, or on any subsequent observation?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subsequent&lt;/LI&gt;&lt;LI&gt;Could the observation with ND=1 and EII=1 be the second (or later) observation for a TN?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Any place for observation&lt;/LI&gt;&lt;LI&gt;How many observations might there be (maximum) for a TN?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 (ND/EII=0/0 or ND/EII=1/0)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I am new in to SAS so it would be really helpful if you would provide the full data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks you for prompt response.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 14:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519121#M3724</guid>
      <dc:creator>Sunnykapoor</dc:creator>
      <dc:date>2018-12-06T14:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519126#M3725</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;TN is the unique value&lt;/SPAN&gt;"-- Are you sure? Your example has multiple TN transactions with TN having duplicate keys.&amp;nbsp; And what is your expected output. Either your writing isn't clear or my comprehension is not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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/250275"&gt;@Sunnykapoor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working on data which have several values and I have to compare them.&amp;nbsp;I am trying to use Lag function but unable to get through.&amp;nbsp;Below are the context of data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;MN&lt;/TD&gt;
&lt;TD&gt;TN&lt;/TD&gt;
&lt;TD&gt;EII&lt;/TD&gt;
&lt;TD&gt;ND&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;238552&lt;/TD&gt;
&lt;TD&gt;40006248&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;316969&lt;/TD&gt;
&lt;TD&gt;40006248&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;631788&lt;/TD&gt;
&lt;TD&gt;40006248&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;660798&lt;/TD&gt;
&lt;TD&gt;50098722&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;660007&lt;/TD&gt;
&lt;TD&gt;50098722&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;661359&lt;/TD&gt;
&lt;TD&gt;50098722&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TN is the unique value and scenarios are:&lt;/P&gt;
&lt;P&gt;1) we have to select TN with EII and ND as 1 and 1 only if TN with same number is followed by either EII and ND as 0 and 0 or EII and ND as 1 and 0.&lt;/P&gt;
&lt;P&gt;2) No Duplicate entries for TN.&lt;/P&gt;
&lt;P&gt;Please suggest&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 14:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519126#M3725</guid>
      <dc:creator>Allaluiah</dc:creator>
      <dc:date>2018-12-06T14:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519129#M3727</link>
      <description>&lt;P&gt;You say there is a maximum of 2 observations per TN in your reply, but the sample data you posted contains 3 observations for a TN. At a minimum, you will need to post the output that you expect to see, based on the original data that you post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really don't know enough SAS to begin writing this program, will the answer really be useful to you?&amp;nbsp; Even if it works, how can you tell if it would work for a different set of data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the ND=1 and EII=1 observation is the second one for that TN, should it be compared to all other observations for that TN (including the first one)?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 14:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519129#M3727</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-06T14:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519130#M3728</link>
      <description>&lt;P&gt;My apologies MN is the unique value. expected outcome for example is :&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;MN&lt;/TD&gt;&lt;TD&gt;TN&lt;/TD&gt;&lt;TD&gt;EII&lt;/TD&gt;&lt;TD&gt;ND&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;238552&lt;/TD&gt;&lt;TD&gt;40006248&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 14:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519130#M3728</guid>
      <dc:creator>Sunnykapoor</dc:creator>
      <dc:date>2018-12-06T14:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519132#M3729</link>
      <description>&lt;P&gt;My apologies as MN is the field with unique value, it should be compared with rows having same MN. In data set it can be 2 or 3.&amp;nbsp;I am in learning phase, so trying to&amp;nbsp;grasp how different type of commands work in SAS.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 14:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519132#M3729</guid>
      <dc:creator>Sunnykapoor</dc:creator>
      <dc:date>2018-12-06T14:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519134#M3730</link>
      <description>&lt;P&gt;Assuming I understand your requirement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input MN $	TN$ 	EII	ND ;
cards;
238552	40006248	1	1
316969	40006248	0	0
631788	40006248	1	0
660798	50098722	1	0
660007	50098722	0	0
661359	50098722	1	1
;

data want;
array t(999) _temporary_; 
call missing(of t(*));
do _n=1 by 1 until(last.tn);
set have;
by tn ;
_k=sum(EII,nd);
if _k=2 then _n1=_n;
else if _k=0 and _n-1=_n1 then t(_n)=_n1;
end;
do _n_=1 by 1 until(last.tn);
set have;
by tn;
if _n_ in t then output;
end;
drop _:;
run;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 14:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519134#M3730</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-06T14:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519138#M3732</link>
      <description>&lt;P&gt;A small correction to the previous&lt;/P&gt;
&lt;P&gt;Instead of&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;else if _k=0 and _n-1=_n1 then t(_n)=_n1;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;changed to&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;else if _k in (0,1) and _n-1=_n1 then t(_n)=_n1;&lt;/EM&gt;&lt;/STRONG&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;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input MN $	TN$ 	EII	ND ;
cards;
238552	40006248	1	1
316969	40006248	0	0
631788	40006248	1	0
660798	50098722	1	0
660007	50098722	0	0
661359	50098722	1	1
;

data want;
array t(999) _temporary_; 
call missing(of t(*));
do _n=1 by 1 until(last.tn);
set have;
by tn ;
_k=sum(EII,nd);
if _k=2 then _n1=_n;
else if _k in (0,1) and _n-1=_n1 then t(_n)=_n1;
end;
do _n_=1 by 1 until(last.tn);
set have;
by tn;
if _n_ in t then output;
end;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 14:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519138#M3732</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-06T14:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519139#M3733</link>
      <description>&lt;P&gt;It is showing no result.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 14:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519139#M3733</guid>
      <dc:creator>Sunnykapoor</dc:creator>
      <dc:date>2018-12-06T14:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519142#M3735</link>
      <description>&lt;P&gt;Here is my test:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;LOG:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;127 ;&lt;BR /&gt;128&lt;BR /&gt;129&lt;BR /&gt;130 data want;&lt;BR /&gt;131 array t(999) _temporary_;&lt;BR /&gt;132 call missing(of t(*));&lt;BR /&gt;133 do _n=1 by 1 until(last.tn);&lt;BR /&gt;134 set have;&lt;BR /&gt;135 by tn ;&lt;BR /&gt;136 _k=sum(EII,nd);&lt;BR /&gt;137 if _k=2 then _n1=_n;&lt;BR /&gt;138 else if _k in (0,1) and _n-1=_n1 then t(_n)=_n1;&lt;BR /&gt;139 end;&lt;BR /&gt;140 do _n_=1 by 1 until(last.tn);&lt;BR /&gt;141 set have;&lt;BR /&gt;142 by tn;&lt;BR /&gt;143 if _n_ in t then output;&lt;BR /&gt;144 end;&lt;BR /&gt;145 drop _:;&lt;BR /&gt;146 run;&lt;/P&gt;
&lt;P&gt;NOTE: There were 6 observations read from the data set WORK.HAVE.&lt;BR /&gt;NOTE: There were 6 observations read from the data set WORK.HAVE.&lt;BR /&gt;NOTE: The data set WORK.WANT has 1 observations and 4 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.03 seconds&lt;BR /&gt; cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PRINT RESULTS:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SAS Output&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;The SAS System&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;MN&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;TN&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;EII&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;ND&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;238552&lt;/TD&gt;
&lt;TD class="l data"&gt;40006248&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Dec 2018 14:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519142#M3735</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-06T14:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519143#M3736</link>
      <description>&lt;P&gt;Having the expected outcome is a big help.&amp;nbsp; Here's what I recommend:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by TN;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do until (last.tn);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by tn;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if EII=0 and ND=0 then both_zero='Y';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else if EII=1 and ND=0 then eii_only = 'Y';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.tn);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by tn;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if EII = 1 and ND=1 and (eii_only='Y' or both_zero='Y') then output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop both_zero eii_only;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 15:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Lag-function/m-p/519143#M3736</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-06T15:00:26Z</dc:date>
    </item>
  </channel>
</rss>

