<?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: generating multiple (or repeat) records during data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/generating-multiple-or-repeat-records-during-data-step/m-p/146787#M262063</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Easy indeed. This kind of expansion is rarely needed within SAS. Check the FREQ statement available in most SAS procedures.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input name $ freq;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Fred&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Janice&amp;nbsp;&amp;nbsp; 3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;James&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;one = 1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do i = 1 to freq;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop freq i;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 03 Aug 2014 17:55:15 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2014-08-03T17:55:15Z</dc:date>
    <item>
      <title>generating multiple (or repeat) records during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/generating-multiple-or-repeat-records-during-data-step/m-p/146786#M262062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Been a while since I tried this sort of thing with SAS -- probably easy, but at the risk of admitting same... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose I have the following file &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fred&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 &lt;/P&gt;&lt;P&gt;Janice&amp;nbsp;&amp;nbsp; 3 &lt;/P&gt;&lt;P&gt;James&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'd like to do is take this data set, and re-write it, as follows: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fred&amp;nbsp;&amp;nbsp; 1 &lt;/P&gt;&lt;P&gt;Fred&amp;nbsp;&amp;nbsp; 1 &lt;/P&gt;&lt;P&gt;Fred&amp;nbsp;&amp;nbsp; 1 &lt;/P&gt;&lt;P&gt;Fred&amp;nbsp;&amp;nbsp; 1 &lt;/P&gt;&lt;P&gt;Janice 1 &lt;/P&gt;&lt;P&gt;Janice 1 &lt;/P&gt;&lt;P&gt;Janice 1 &lt;/P&gt;&lt;P&gt;James&amp;nbsp; 1 &lt;/P&gt;&lt;P&gt;James&amp;nbsp; 1 &lt;/P&gt;&lt;P&gt;James&amp;nbsp; 1 &lt;/P&gt;&lt;P&gt;James&amp;nbsp; 1 &lt;/P&gt;&lt;P&gt;James&amp;nbsp; 1 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In other words, the right-hand field in the original data st is the frequency with which I want to repeat the user (first field) in the new file. So, I want 'Fred' to show up 4 times, Janice 3 times, and James 5 times. And, at the end of each record, the number '1'.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Aug 2014 17:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/generating-multiple-or-repeat-records-during-data-step/m-p/146786#M262062</guid>
      <dc:creator>JohnnyCanuck</dc:creator>
      <dc:date>2014-08-03T17:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: generating multiple (or repeat) records during data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/generating-multiple-or-repeat-records-during-data-step/m-p/146787#M262063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Easy indeed. This kind of expansion is rarely needed within SAS. Check the FREQ statement available in most SAS procedures.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input name $ freq;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Fred&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Janice&amp;nbsp;&amp;nbsp; 3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;James&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;one = 1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do i = 1 to freq;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop freq i;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Aug 2014 17:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/generating-multiple-or-repeat-records-during-data-step/m-p/146787#M262063</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-08-03T17:55:15Z</dc:date>
    </item>
  </channel>
</rss>

