<?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: Repeating N number of observations in data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300743#M63565</link>
    <description>&lt;P&gt;I attached a simplified version of what I want. &amp;nbsp;The first tab is where I am at, and the second is where I hope to end up through data step.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Sep 2016 12:43:42 GMT</pubDate>
    <dc:creator>dsriggs</dc:creator>
    <dc:date>2016-09-26T12:43:42Z</dc:date>
    <item>
      <title>Repeating N number of observations in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300353#M63427</link>
      <description>&lt;P&gt;I have a work file with 12 observations one for each month, and then for future months I have blank or null values. &amp;nbsp;What I want to do is repeat those 12 observations for all of the blank or null values. &amp;nbsp;I know about the retain function, but this just carries down the last observation, how can I repeat the last 12? &amp;nbsp;If this can be done in data step that would be preferable.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 12:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300353#M63427</guid>
      <dc:creator>dsriggs</dc:creator>
      <dc:date>2016-09-23T12:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating N number of observations in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300356#M63428</link>
      <description>&lt;P&gt;It is called a do loop:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  do i=1 to 10;
    output;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;This is just an example, each record in have gets output 10 times. &amp;nbsp;If you post example test data (in the form of a datastep) and what you want the output to look like the code can be customised.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 13:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300356#M63428</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-23T13:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating N number of observations in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300395#M63439</link>
      <description>&lt;P&gt;If &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;'s solution does not match you needs please provide an example starting set and the desired result.&lt;/P&gt;
&lt;P&gt;Also the solution may require sorting to get into a specific order.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 14:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300395#M63439</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-23T14:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating N number of observations in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300743#M63565</link>
      <description>&lt;P&gt;I attached a simplified version of what I want. &amp;nbsp;The first tab is where I am at, and the second is where I hope to end up through data step.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2016 12:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300743#M63565</guid>
      <dc:creator>dsriggs</dc:creator>
      <dc:date>2016-09-26T12:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating N number of observations in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300796#M63578</link>
      <description>&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This link shows instructions on how you can create datastep code from your SAS dataset to provide data that we can test code against or fully understand the contents: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Paste the text or attach as a text file.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2016 16:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/300796#M63578</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-26T16:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating N number of observations in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/303674#M64551</link>
      <description>&lt;P&gt;I can't download the zip file from that link on my work computer. &amp;nbsp;Here is a text version of what I have and what I want. No downloading required. &amp;nbsp;Both month and 'x'&amp;nbsp;are of type numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Have:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;month x&lt;BR /&gt;1/1/2013 0.65&lt;BR /&gt;2/1/2013 0.96&lt;BR /&gt;3/1/2013 0.07&lt;BR /&gt;4/1/2013 0.15&lt;BR /&gt;5/1/2013 0.90&lt;BR /&gt;6/1/2013 0.34&lt;BR /&gt;7/1/2013 0.10&lt;BR /&gt;8/1/2013 0.42&lt;BR /&gt;9/1/2013 0.09&lt;BR /&gt;10/1/2013 0.28&lt;BR /&gt;11/1/2013 0.31&lt;BR /&gt;12/1/2013 0.79&lt;STRONG&gt;&lt;BR /&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;&lt;STRONG&gt;Want:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;month x&lt;BR /&gt;1/1/2013 0.65&lt;BR /&gt;2/1/2013 0.96&lt;BR /&gt;3/1/2013 0.07&lt;BR /&gt;4/1/2013 0.15&lt;BR /&gt;5/1/2013 0.90&lt;BR /&gt;6/1/2013 0.34&lt;BR /&gt;7/1/2013 0.10&lt;BR /&gt;8/1/2013 0.42&lt;BR /&gt;9/1/2013 0.09&lt;BR /&gt;10/1/2013 0.28&lt;BR /&gt;11/1/2013 0.31&lt;BR /&gt;12/1/2013 0.79&lt;BR /&gt;1/1/2014 0.65&lt;BR /&gt;2/1/2014 0.96&lt;BR /&gt;3/1/2014 0.07&lt;BR /&gt;4/1/2014 0.15&lt;BR /&gt;5/1/2014 0.90&lt;BR /&gt;6/1/2014 0.34&lt;BR /&gt;7/1/2014 0.10&lt;BR /&gt;8/1/2014 0.42&lt;BR /&gt;9/1/2014 0.09&lt;BR /&gt;10/1/2014 0.28&lt;BR /&gt;11/1/2014 0.31&lt;BR /&gt;12/1/2014 0.79&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 21:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/303674#M64551</guid>
      <dc:creator>dsriggs</dc:creator>
      <dc:date>2016-10-10T21:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating N number of observations in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/303696#M64558</link>
      <description>&lt;P&gt;Here you go.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input month_begin_dt :mmddyy10. x :best32.;
  format month_begin_dt date9.;
datalines;
1/1/2013 0.65
2/1/2013 0.96
3/1/2013 0.07
4/1/2013 0.15
5/1/2013 0.90
6/1/2013 0.34
7/1/2013 0.10
8/1/2013 0.42
9/1/2013 0.09
10/1/2013 0.28
11/1/2013 0.31
12/1/2013 0.79
;
run;

/** option 1 **/
data template;
  month_begin_dt='01jan2013'd;
  format month_begin_dt date9.;
  do while(month_begin_dt&amp;lt;='01dec2014'd);
    output;
    month_begin_dt=intnx('month',month_begin_dt,1,'b');
  end;
run;

proc sql;
  create table want1 as
  select b.month_begin_dt, a.x
  from have as A inner join template as B
    on month(a.month_begin_dt)=month(b.month_begin_dt)
  order by month_begin_dt
  ;
quit;

/** option 2 **/
data want2;
  set have;
  output;
  month_begin_dt=intnx('month',month_begin_dt,12,'b');
  output;
run;

proc sort data=want2;
  by month_begin_dt;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Oct 2016 01:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-N-number-of-observations-in-data-step/m-p/303696#M64558</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-11T01:35:08Z</dc:date>
    </item>
  </channel>
</rss>

