<?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 all rows of a dataset n times in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407812#M99405</link>
    <description>&lt;P&gt;Are you sure you don't want to do a many to one merge instead?&amp;nbsp; If you really want to make copies of observations, just used a DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data class(drop=i);
   set sashelp.class;
   do i = 1 to 1000;
      output;
      end;
   run;
   &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Oct 2017 20:08:32 GMT</pubDate>
    <dc:creator>WarrenKuhfeld</dc:creator>
    <dc:date>2017-10-26T20:08:32Z</dc:date>
    <item>
      <title>Replicate all rows of a dataset n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407797#M99399</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a bit of trouble with replicating every row in my dataset n times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is to merge 4003 subjects from 44 groups, replicated 1000 times, with 1000 rows of logistic model parameter estimates from 1000 bootstrapped samples of my original data, for each of the 4003 subjects. Each subject has1000 consecutive rows (1,1,1,...(1000 times), 2,2,2,...), and the 1000 parameter estimate rows need to be repeated (1,2,3...1000, 1,2,3,...1000, (4003 times)).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm going to then evaluate each subject with the 1000 logistic models, and then find the mean and se for the odds ratio CI, by group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Patrick&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 19:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407797#M99399</guid>
      <dc:creator>ibenp</dc:creator>
      <dc:date>2017-10-26T19:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate all rows of a dataset n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407812#M99405</link>
      <description>&lt;P&gt;Are you sure you don't want to do a many to one merge instead?&amp;nbsp; If you really want to make copies of observations, just used a DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data class(drop=i);
   set sashelp.class;
   do i = 1 to 1000;
      output;
      end;
   run;
   &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Oct 2017 20:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407812#M99405</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-10-26T20:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate all rows of a dataset n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407816#M99406</link>
      <description>&lt;P&gt;This works for creating 1000 consecutive rows of the same row, but not all 1000 rows repeated 1000 times.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 20:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407816#M99406</guid>
      <dc:creator>ibenp</dc:creator>
      <dc:date>2017-10-26T20:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate all rows of a dataset n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407818#M99407</link>
      <description>&lt;P&gt;Is this what you are asking?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class(drop=i);
   do i = 1 to 1000;
      do j = 1 to n;
         set sashelp.class nobs=n point=j;
         output;
         end;
      end;
   stop;
   run;
   &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Oct 2017 20:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407818#M99407</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-10-26T20:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate all rows of a dataset n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407822#M99408</link>
      <description>&lt;P&gt;YES, this worked for me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Project2.Beta3_repeated_4003_times(drop=i);&lt;BR /&gt;do i = 1 to 4003;&lt;BR /&gt;do j = 1 to n;&lt;BR /&gt;set Project2.Beta3 nobs=n point=j;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 20:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407822#M99408</guid>
      <dc:creator>ibenp</dc:creator>
      <dc:date>2017-10-26T20:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate all rows of a dataset n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407868#M99422</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/126288"&gt;@ibenp&lt;/a&gt;&amp;nbsp;please mark the question answered by selecting the correct solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 00:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407868#M99422</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-27T00:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Replicate all rows of a dataset n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407908#M99446</link>
      <description>&lt;P&gt;Reading a file 4003 times using the POINT= approach (i.e. direct access to records) is probably a lot slower than finding a way to let SAS use its intrinsically&amp;nbsp;faster sequential access.&amp;nbsp; And if your dataset is large, it's worth finding a faster approach that effectively uses SAS sequential data access engine.&amp;nbsp; Beyond that,&amp;nbsp;using PROC append would be more like a "bulk load" of the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course you really don't want to run 4003 iterations of PROC APPEND.&amp;nbsp; And you don't have to.&amp;nbsp; This program &lt;EM&gt;&lt;STRONG&gt;concatenates the data set to itself&lt;/STRONG&gt;&lt;/EM&gt;, meaning it doubles in size at every iteration.&amp;nbsp; So if you were to ask for N=4096, you'd have 12 iterations.&amp;nbsp; For N=4003, &amp;nbsp;you have 11 iterations and a 12th "partial" iteration, adding a fraction of the data set to itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let nreps=4003;

 data _null_;
  maxpower=floor(log2(&amp;amp;nreps));
  put maxpower=;
  call execute('data class;set sashelp.class;run;');
  do power=1 to maxpower;
    call execute('proc append base=class data=class;run;');
  end;

  if 0 then set sashelp.class nobs=nrecs;
  obs_to_add=nrecs*(&amp;amp;nreps - 2**maxpower);
  if  obs_to_add&amp;gt;0 then 
    call execute(cats('proc append base=class data=class (obs=',obs_to_add,');run;'));
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 04:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replicate-all-rows-of-a-dataset-n-times/m-p/407908#M99446</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-27T04:27:14Z</dc:date>
    </item>
  </channel>
</rss>

