<?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: Replicate multiple results across rows in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511015#M2079</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, I'm not entirely sure here, since I'm not an expert on hash objects &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I agree that &lt;STRONG&gt;famid&lt;/STRONG&gt; does not have to be a key variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I think a new&lt;I&gt;&amp;nbsp;&lt;/I&gt;instance&amp;nbsp;of the hash object h for each by group is created with this approach, which would not reduce memory consumption.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps something like this?&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 want(drop=rc);
   if _N_=1 then do;
      declare hash h();
      h.definekey('implicate');
      h.definedata('imp_inc');
      h.definedone();
   end;

   set have;
   by famid;

   if indid = 1 then rc = h.add();
   else rc = h.find();

   if last.famid then h.clear();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Nov 2018 13:13:31 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-11-07T13:13:31Z</dc:date>
    <item>
      <title>Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510985#M2070</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data structure that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA have ; &lt;BR /&gt;INPUT famid indid implicate imp_inc; &lt;BR /&gt;CARDS ; &lt;BR /&gt;1 1 1 40000&lt;BR /&gt;1 1 2 25000&lt;BR /&gt;1 1 3 34000&lt;BR /&gt;1 1 4 23555&lt;BR /&gt;1 1 5 49850&lt;BR /&gt;1 2 1 1000&lt;BR /&gt;1 2 2 2000&lt;BR /&gt;1 2 3 3000&lt;BR /&gt;1 2 4 4000&lt;BR /&gt;1 2 5 5000&lt;BR /&gt;1 3 1 .&lt;BR /&gt;1 3 2 .&lt;BR /&gt;1 3 3 .&lt;BR /&gt;1 3 4 .&lt;BR /&gt;1 3 5 .&lt;BR /&gt;2 1 1 40000&lt;BR /&gt;2 1 2 45000&lt;BR /&gt;2 1 3 50000&lt;BR /&gt;2 1 4 34000&lt;BR /&gt;2 1 5 23500&lt;BR /&gt;2 2 1 .&lt;BR /&gt;2 2 2 .&lt;BR /&gt;2 2 3 .&lt;BR /&gt;2 2 4 .&lt;BR /&gt;2 2 5 .&lt;BR /&gt;2 3 1 41000&lt;BR /&gt;2 3 2 39000&lt;BR /&gt;2 3 3 24000&lt;BR /&gt;2 3 4 32000&lt;BR /&gt;2 3 5 53000&lt;BR /&gt;RUN ;&lt;/PRE&gt;&lt;P&gt;So, we have family id, individual id, implicate number and imputed income for each implicate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i need is to replicate the results of&amp;nbsp; the first individual in each family (all of the five implicates) for the remaining individuals within each family, replacing whatever values we previously had on those cells, like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want ; 
INPUT famid indid implicate imp_inc; 
CARDS ; 
1 1 1 40000
1 1 2 25000
1 1 3 34000
1 1 4 23555
1 1 5 49850
1 2 1 40000
1 2 2 25000
1 2 3 34000
1 2 4 23555
1 2 5 49850
1 3 1 40000
1 3 2 25000
1 3 3 34000
1 3 4 23555
1 3 5 49850
2 1 1 40000
2 1 2 45000
2 1 3 50000
2 1 4 34000
2 1 5 23500
2 2 1 40000
2 2 2 45000
2 2 3 50000
2 2 4 34000
2 2 5 23500
2 3 1 40000
2 3 2 45000
2 3 3 50000
2 3 4 34000
2 3 5 23500
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this example I'm trying to replicate only one variable but in my project I will have to do this for dozens of variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far, I came up with this solution:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let implist_1=imp_inc;

%macro copyv1(list);
	%let nwords=%sysfunc(countw(&amp;amp;list));
	%do i=1 %to &amp;amp;nwords;
	%let varl=%scan(&amp;amp;list, &amp;amp;i);
		proc means data=have max noprint;
			var &amp;amp;varl;
			by famid implicate;
			where indid=1;
			OUTPUT OUT=copy max=max_&amp;amp;varl;	
		run;
		data want;
	 		set have;
			drop &amp;amp;varl;
		run;
		data want (drop=_TYPE_ _FREQ_);
			merge want copy;
			by famid implicate;
			rename max_&amp;amp;varl=&amp;amp;varl;
		run;
	%end;
%mend;
%copyv1(&amp;amp;imp_list1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This works well for one or two variables. However it is tremendously slow once you do it for 400 variables in a data-set with the size of 1.5 GB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm pretty sure there is a faster way to do this with some form of proc sql or first.var etc., but i'm relatively new to SAS and so far I couldn't come up with a better solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 10:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510985#M2070</guid>
      <dc:creator>Luis_Martins</dc:creator>
      <dc:date>2018-11-07T10:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510993#M2072</link>
      <description>&lt;P&gt;Do the 400 variables of interest have some common naming convention?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 11:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510993#M2072</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-11-07T11:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510994#M2073</link>
      <description>&lt;P&gt;Unfortunately, no. They may have very different and unrelated names.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 11:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510994#M2073</guid>
      <dc:creator>Luis_Martins</dc:creator>
      <dc:date>2018-11-07T11:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510996#M2074</link>
      <description>&lt;P&gt;Ok. But the principle for all variables is the same: If they are missing, their value should be replaced by one of the first 5 values (first missing replaced by first value etc.) for the given by group, correct?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 11:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510996#M2074</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-11-07T11:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510998#M2075</link>
      <description>&lt;P&gt;I think this does what you want (if my assessments are correct), is reasonable fast and should not spend too much memory&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I added three other variables with different values and no common naming conventions so you can easily edit the code according to your needs &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input famid indid implicate imp_inc; 
somevar=imp_inc*2;
othervar=imp_inc*3;
thirdvar=imp_inc*4;
cards ; 
1 1 1 40000
1 1 2 25000
1 1 3 34000
1 1 4 23555
1 1 5 49850
1 2 1 1000
1 2 2 2000
1 2 3 3000
1 2 4 4000
1 2 5 5000
1 3 1 .
1 3 2 .
1 3 3 .
1 3 4 .
1 3 5 .
2 1 1 40000
2 1 2 45000
2 1 3 50000
2 1 4 34000
2 1 5 23500
2 2 1 .
2 2 2 .
2 2 3 .
2 2 4 .
2 2 5 .
2 3 1 41000
2 3 2 39000
2 3 3 24000
2 3 4 32000
2 3 5 53000
run;

data want(drop=rc);
   if _N_=1 then do;
      declare hash h(dataset:'have(where=(indid=1))');
      h.definekey('famid', 'implicate');
      h.definedata('imp_inc', 'somevar', 'othervar', 'thirdvar');
      h.definedone();
   end;

   set have;
   by famid;
   
   if imp_inc ne 1 then rc=h.find();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if this does not meet your needs or you need some clarification&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 12:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/510998#M2075</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-11-07T12:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511006#M2077</link>
      <description>&lt;P&gt;I think this will do the same, but reduce the memory consumption to the bare minimum:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=rc);
set have;
by famid;
if first.famid
then do;
  declare hash h();
  h.definekey('implicate');
  h.definedata('imp_inc');
  h.definedone();
end;
if indid = 1
then rc = h.add();
else rc = h.find();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 12:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511006#M2077</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-07T12:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511015#M2079</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, I'm not entirely sure here, since I'm not an expert on hash objects &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I agree that &lt;STRONG&gt;famid&lt;/STRONG&gt; does not have to be a key variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I think a new&lt;I&gt;&amp;nbsp;&lt;/I&gt;instance&amp;nbsp;of the hash object h for each by group is created with this approach, which would not reduce memory consumption.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps something like this?&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 want(drop=rc);
   if _N_=1 then do;
      declare hash h();
      h.definekey('implicate');
      h.definedata('imp_inc');
      h.definedone();
   end;

   set have;
   by famid;

   if indid = 1 then rc = h.add();
   else rc = h.find();

   if last.famid then h.clear();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 13:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511015#M2079</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-11-07T13:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511017#M2080</link>
      <description>&lt;P&gt;Works great thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 13:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511017#M2080</guid>
      <dc:creator>Luis_Martins</dc:creator>
      <dc:date>2018-11-07T13:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511019#M2081</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, I'm not entirely sure here, since I'm not an expert on hash objects &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I agree that &lt;STRONG&gt;famid&lt;/STRONG&gt; does not have to be a key variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I think a new&lt;I&gt;&amp;nbsp;&lt;/I&gt;instance&amp;nbsp;of the hash object h for each by group is created with this approach, which would not reduce memory consumption.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps something like this?&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 want(drop=rc);
   if _N_=1 then do;
      declare hash h();
      h.definekey('implicate');
      h.definedata('imp_inc');
      h.definedone();
   end;

   set have;
   by famid;

   if indid = 1 then rc = h.add();
   else rc = h.find();

   if last.famid then h.clear();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you are right. After re-reading the documentation for the declare statement, it "instantiates" the object; it can well be that the old object is "orphaned" and just keeps on hanging around in memory limbo. Your solution prevents this and does the same re-initialization at group change that I wanted to achieve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My main goal was to prevent the loading of a major part of the dataset into memory when only the data of the current group is needed.&lt;/P&gt;
&lt;P&gt;If one positively knew that only 5 indid can exist for any given family, a temporary array could also be used to propagate the values. But the hash object is more flexible, and additional variables need only be added to the definedata() method, which can be neatly accomplished by reading them into a macro variable from dictionary.columns.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 13:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511019#M2081</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-07T13:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511038#M2085</link>
      <description>&lt;P&gt;A temp array might be faster&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA have ; 
INPUT famid indid implicate imp_inc; 
CARDS ; 
1 1 1 40000
1 1 2 25000
1 1 3 34000
1 1 4 23555
1 1 5 49850
1 2 1 1000
1 2 2 2000
1 2 3 3000
1 2 4 4000
1 2 5 5000
1 3 1 .
1 3 2 .
1 3 3 .
1 3 4 .
1 3 5 .
2 1 1 40000
2 1 2 45000
2 1 3 50000
2 1 4 34000
2 1 5 23500
2 2 1 .
2 2 2 .
2 2 3 .
2 2 4 .
2 2 5 .
2 3 1 41000
2 3 2 39000
2 3 3 24000
2 3 4 32000
2 3 5 53000
;
RUN ;

data want;
array t(999) _temporary_;
call missing(of t(*));
do until(last.famid);
set have;
by famid;
if indid=1 then t(implicate)=imp_inc;
else imp_inc=t(implicate);
output;
end;
run;




&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Nov 2018 14:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511038#M2085</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-07T14:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511040#M2086</link>
      <description>&lt;P&gt;Hash is OK here but can really get unwieldy. There is not that much need to load, look up using dot notation method at least for your data which assuming your sample is pretty good representative is a very straight forward simple one pass that doesn't really warrant external data structure requirement as such in my opinion.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 14:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511040#M2086</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-07T14:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511041#M2087</link>
      <description>&lt;P&gt;I did some tests with options fullstimer. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;'s improvement on my solution is the one to use, as it has the lowest memory consumption and is quicker than his original method.&lt;/P&gt;
&lt;P&gt;My initial suggestion is faulty, as it is the first one to crash when the dataset is expanded.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 14:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511041#M2087</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-07T14:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511045#M2088</link>
      <description>&lt;P&gt;The temporaray array proves to be the fastest and consumes the least memory, but I think expanding it for more variables will be less straightforward than the hash method, as you would need to create a two-dimensional temporary array and a corresponding array for the existing variables that are filled and scanned in a do loop.&lt;/P&gt;
&lt;P&gt;Personally, I like the hash approach as its core part&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if indid = 1
then rc = h.add();
else rc = h.find();
if last.famid then rc = h.clear();
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will stay the same no matter how many variables need to be dealt with, and no assumptions need to be made (size of array) for the possible number of individuals in a family.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 14:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511045#M2088</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-07T14:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511047#M2090</link>
      <description>&lt;P&gt;Sure and right, however for OPs requirement exclusively here, I think temp array alone should suffice. This is something I am seriously &lt;U&gt;assuming&lt;/U&gt; OP has presented the sample that is representative of what he/she has in real.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 14:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511047#M2090</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-07T14:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511048#M2091</link>
      <description>&lt;P&gt;If you want to run the tests yourself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do famid = 1 to 100000;
  do indid = 1 to 5;
    do implicate = 1 to 5;
      imp_inc = 10000; /* just some value */
      output;
    end;
  end;
end;
run;

options fullstimer;

data want (drop=rc);
set have;
by famid;
if _n_ = 1
then do;
  declare hash h();
  h.definekey('implicate');
  h.definedata('imp_inc');
  h.definedone();
end;
if indid = 1
then rc = h.add();
else rc = h.find();
if last.famid then rc = h.clear();
run;

data want(drop=rc);
   if _N_=1 then do;
      declare hash h(dataset:'have(where=(indid=1))');
      h.definekey('famid', 'implicate');
      h.definedata('imp_inc');
      h.definedone();
   end;

   set have;
   by famid;
   
   if imp_inc ne 1 then rc=h.find();
run;

data want;
array t(999) _temporary_;
call missing(of t(*));
do until(last.famid);
  set have;
  by famid;
  if indid=1 then t(implicate)=imp_inc;
  else imp_inc=t(implicate);
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If it doesn't show you decisive results, just increase the loop counts in the dataset creation.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 14:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511048#M2091</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-07T14:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate multiple results across rows</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511049#M2092</link>
      <description>&lt;P&gt;Thank you sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; I was lazy to create bigger samples but you made it easy to test and here i did for 1 million families&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;67 data have;&lt;BR /&gt;68&lt;STRONG&gt; do famid = 1 to 1e6;&lt;/STRONG&gt;&lt;BR /&gt;69 do indid = 1 to 5;&lt;BR /&gt;70 do implicate = 1 to 5;&lt;BR /&gt;71 imp_inc = 10000; /* just some value */&lt;BR /&gt;72 output;&lt;BR /&gt;73 end;&lt;BR /&gt;74 end;&lt;BR /&gt;75 end;&lt;BR /&gt;76 run;&lt;/P&gt;
&lt;P&gt;NOTE: The data set WORK.HAVE has 25000000 observations and 4 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 1.63 seconds&lt;BR /&gt; cpu time 1.62 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;77 data want1;&lt;BR /&gt;78 array t(999) _temporary_;&lt;BR /&gt;79 call missing(of t(*));&lt;BR /&gt;80 do until(last.famid);&lt;BR /&gt;81 set have;&lt;BR /&gt;82 by famid;&lt;BR /&gt;83 if indid=1 then t(implicate)=imp_inc;&lt;BR /&gt;84 else imp_inc=t(implicate);&lt;BR /&gt;85 output;&lt;BR /&gt;86 end;&lt;BR /&gt;87 run;&lt;/P&gt;
&lt;P&gt;NOTE: There were 25000000 observations read from the data set WORK.HAVE.&lt;BR /&gt;NOTE: The data set WORK.WANT1 has 25000000 observations and 4 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 3.87 seconds&lt;BR /&gt; cpu time 3.29 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;88&lt;BR /&gt;89 data want (drop=rc);&lt;BR /&gt;90 set have;&lt;BR /&gt;91 by famid;&lt;BR /&gt;92 if _n_ = 1&lt;BR /&gt;93 then do;&lt;BR /&gt;94 declare hash h();&lt;BR /&gt;95 h.definekey('implicate');&lt;BR /&gt;96 h.definedata('imp_inc');&lt;BR /&gt;97 h.definedone();&lt;BR /&gt;98 end;&lt;BR /&gt;99 if indid = 1&lt;BR /&gt;100 then rc = h.add();&lt;BR /&gt;101 else rc = h.find();&lt;BR /&gt;102 if last.famid then rc = h.clear();&lt;BR /&gt;103 run;&lt;/P&gt;
&lt;P&gt;NOTE: There were 25000000 observations read from the data set WORK.HAVE.&lt;BR /&gt;NOTE: The data set WORK.WANT has 25000000 observations and 4 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 5.82 seconds&lt;BR /&gt; cpu time 5.70 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 15:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Replicate-multiple-results-across-rows/m-p/511049#M2092</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-07T15:02:17Z</dc:date>
    </item>
  </channel>
</rss>

