<?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: carry forward the value both up and down rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633875#M188082</link>
    <description>Yes, thank you very much for your time .</description>
    <pubDate>Sat, 21 Mar 2020 20:26:42 GMT</pubDate>
    <dc:creator>sahoositaram555</dc:creator>
    <dc:date>2020-03-21T20:26:42Z</dc:date>
    <item>
      <title>carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633839#M188059</link>
      <description>&lt;P&gt;Hi everyone, I have a dataset below.&lt;/P&gt;
&lt;P&gt;for every subjid i have randno for only the baseline visit . i would like to carry forward that randno value both to screening and subsequent visits like 12weeks ,24weeks,32weeks. it has to be done like that by each subject id both upper row and below rows.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data main;&lt;/P&gt;
&lt;P&gt;Input subjid visit randno;&lt;/P&gt;
&lt;P&gt;Cards&lt;/P&gt;
&lt;P&gt;10001&amp;nbsp;&amp;nbsp;&amp;nbsp; screening&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;10001&amp;nbsp;&amp;nbsp;&amp;nbsp; baseline&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; 90001&lt;/P&gt;
&lt;P&gt;10001&amp;nbsp;&amp;nbsp;&amp;nbsp; 12_weeks&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;10001&amp;nbsp;&amp;nbsp;&amp;nbsp; 24_weeks&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;10002&amp;nbsp;&amp;nbsp;&amp;nbsp; screening&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;10002&amp;nbsp;&amp;nbsp;&amp;nbsp; baseline&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; 90010&lt;/P&gt;
&lt;P&gt;10002&amp;nbsp;&amp;nbsp;&amp;nbsp; 12_weeks&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;10002&amp;nbsp;&amp;nbsp;&amp;nbsp; 48_weeks&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;10003&amp;nbsp;&amp;nbsp;&amp;nbsp; screening&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;10003&amp;nbsp;&amp;nbsp;&amp;nbsp; baseline&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; 90011&lt;/P&gt;
&lt;P&gt;10003&amp;nbsp;&amp;nbsp;&amp;nbsp; 12_weeks&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;10003&amp;nbsp;&amp;nbsp;&amp;nbsp; 24_weeks&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;10003&amp;nbsp;&amp;nbsp;&amp;nbsp; 36_weeks&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;Run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can you suggest what method would be appropriate to proceed?&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 19:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633839#M188059</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-03-21T19:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633842#M188062</link>
      <description>&lt;P&gt;Can a Subjid containg more than one non missing value? And what if it does?&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 19:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633842#M188062</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-21T19:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633847#M188064</link>
      <description>&lt;P&gt;Very good point by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;. Until then for what it's worth as I am bored&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data main;

Input subjid visit :$32.  randno;

Cards;

10001    screening            .

10001    baseline               90001

10001    12_weeks           .

10001    24_weeks           .

10002    screening            .

10002    baseline               90010

10002    12_weeks           .

10002    48_weeks           .

10003    screening            .

10003    baseline               90011

10003    12_weeks           .

10003    24_weeks           .

10003    36_weeks           .

;

Run;

proc sql;
create table want as
select subjid ,visit ,max((visit='baseline')*randno) as randno
from (select *,monotonic() as rn from main)
group by subjid
order by subjid,rn;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Mar 2020 19:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633847#M188064</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-21T19:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633850#M188065</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;. i had received the data like that. it means the randomisation number was assigned to them at the baseline visit , not before . Also after baseline they ideally must carry the randno along but due to some app error the value coulnot get loaded, so i want to do it through programming.</description>
      <pubDate>Sat, 21 Mar 2020 19:15:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633850#M188065</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-03-21T19:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633853#M188067</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 merge main(drop=randno) main(keep=visit subjid randno rename=(visit=v) where=(v='baseline'));
 by subjid;
 drop v;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Mar 2020 19:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633853#M188067</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-21T19:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633854#M188068</link>
      <description>&lt;P&gt;Ok. See if this helps you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data main;
Input subjid $ 1-5 visit $ 7-15 randno;
Cards;
10001 screening .    
10001 baseline  90001
10001 12_weeks  .    
10001 24_weeks  .    
10002 screening .    
10002 baseline  90010
10002 12_weeks  .    
10002 48_weeks  .    
10003 screening .    
10003 baseline  90011
10003 12_weeks  .    
10003 24_weeks  .    
10003 36_weeks  .    
;

data want (drop=_:);
   do _N_=1 by 1 until (last.subjid);
      set main;
      by subjid;
      _randno = max(_randno, randno);
   end;
   do _N_=1 to _N_;
      set main;
      randno=_randno;
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Mar 2020 19:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633854#M188068</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-21T19:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633857#M188071</link>
      <description>&lt;P&gt;This is also a great case for somebody who is a beginner of HASH to get the understanding&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
 if _n_=1 then do;
   dcl hash H (dataset:'main(where=(visit="baseline")') ;
   h.definekey  ("subjid") ;
   h.definedata ("randno") ;
   h.definedone () ;
 end;
 set main;
 _n_=h.find();
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 19:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633857#M188071</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-21T19:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633870#M188077</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;, Thank you very much for showing multiple ways of doing this. &lt;BR /&gt;My i know what exactly below statement does to code? its a bit confusing when i'm trying to correlate with the group by statement. &lt;BR /&gt;max((visit='baseline')*randno)&lt;BR /&gt;&lt;BR /&gt;please can you drop a line.</description>
      <pubDate>Sat, 21 Mar 2020 20:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633870#M188077</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-03-21T20:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633873#M188080</link>
      <description>&lt;P&gt;&lt;SPAN&gt;max((visit='baseline')*randno) is merely a fancy boolean expression. So to learn&amp;nbsp; how the expression works is by breaking down to smaller fragments&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. When visit='baseline' is true, the expression evaluates to 1 and when it is false, the expression evaluates to 0. So you would have values of 1's ad 0's&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. You multiply the evaluated 1's and 0's with the randno. This would result in an expression like 1*90001 for subjid 110001 and the same applies for other subjid's&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. Then you take the MAX value of the result of 2, which is max of (90001,0 , 0,0,.... and so forth of 0's). Of course, You are bound to get 90001 in this case. and likewise the same logic would hold true for other subjids&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;4. Proc SQL is awesome as it can be used as readymeals solutions for many cases as along as the dataset is narrow with its capacity to remerge automatically. I really like this functionality that makes many datastep solutions innocent.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Well, there you go. I hope that helps?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 20:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633873#M188080</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-21T20:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633874#M188081</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/109034"&gt;@sahoositaram555&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;, Thank you very much for showing multiple ways of doing this. &lt;BR /&gt;My i know what exactly below statement does to code? its a bit confusing when i'm trying to correlate with the group by statement. &lt;BR /&gt;max((visit='baseline')*randno)&lt;BR /&gt;&lt;BR /&gt;please can you drop a line.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think that statement was designed to insure permanently job stability maintaining the code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's break it down and see what it does and then try guess at why it might help with this problem.&amp;nbsp; The boolean expression VISIT='baseline' will evaluate to 0 (false) or 1(true).&amp;nbsp; The multiplication operator will multiply that value times the value of RANDNO.&amp;nbsp; Then the MAX() aggregate function from SQL will take the largest result over all of the records for that subject.&amp;nbsp; SAS will then re-merge that subject level onto all of the observations it returns for that subject.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that this will work in SQL only if RANDNO was defined as numeric.&amp;nbsp; Unlike a DATA step SQL does not automatically convert character strings to numbers.&amp;nbsp; Note if RANDNO is a numeric variable then that is another coding error in the design of your dataset.&amp;nbsp; You do not ever need to do arithmetic with the values of the RANDNO variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 20:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633874#M188081</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-21T20:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633875#M188082</link>
      <description>Yes, thank you very much for your time .</description>
      <pubDate>Sat, 21 Mar 2020 20:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633875#M188082</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-03-21T20:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633877#M188084</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;,if you can,please help with one quick response. &lt;BR /&gt;That will be helpful to get me this one completely as well. In the second do loop when you mentioned that do _N_=1 to _N_; &lt;BR /&gt; does the second  _N_ means till end of obs . it's a bit unclear to me as we are not using  a by statement in the second DO loop to get all the visit rows per subject . how is it all happening ?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 21 Mar 2020 20:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633877#M188084</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-03-21T20:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633879#M188085</link>
      <description>&lt;P&gt;_N_ here is an index variable for a loop and is just a normal variable that is not written to the output dataset or in other words automatically dropped.&amp;nbsp; When you do use this _N_ variable for anything other than its original stated purpose(&lt;EM&gt;i.e data step iteration counter&lt;/EM&gt;) you are basically controlling the value of the variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the 1st loop, you use SET statement to read observations in a BY GROUP one by one. The compiler sets the value of FIRST. and LAST. variables at compile time determining the first and last observations of the BY GROUP.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have read the observations of a particular by group, you do not need to reset the FIRST and LAST variable values as you can read directly from cache in memory. This saves the compiler from doing extra work and the index variable _N_ value becomes the number of observations to read from the dataset during the 2nd loop. This kind of mimics a self join per se though not quite the same. This technique is also known as DOW loop.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 20:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633879#M188085</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-21T20:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633880#M188086</link>
      <description>&lt;P&gt;If you reverse the operands of the merge statement, you can simplify even a bit more:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge main (where=(visit='baseline')) main (drop=randno);
  by subjid;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Mar 2020 20:54:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633880#M188086</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-03-21T20:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: carry forward the value both up and down rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633887#M188091</link>
      <description>&lt;P&gt;The first loop counts how many and the second loop uses the count to know how many times to execute.&lt;/P&gt;
&lt;P&gt;Your problem does not need the count for anything so it is probably easier to eliminate the counter and just code both loops the same.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
   do until (last.subjid);
      set main;
      by subjid;
      _randno = max(_randno, randno);
   end;
   do until (last.subjid);
      set main;
      by subjid;
      output;
   end;
  drop _randno;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 22:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/carry-forward-the-value-both-up-and-down-rows/m-p/633887#M188091</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-21T22:20:43Z</dc:date>
    </item>
  </channel>
</rss>

