<?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 Simple Program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simple-Program/m-p/76101#M16424</link>
    <description>I have a dataset similar to:&lt;BR /&gt;
&lt;BR /&gt;
age   frequency&lt;BR /&gt;
20       2&lt;BR /&gt;
21       3&lt;BR /&gt;
23       5&lt;BR /&gt;
24       3&lt;BR /&gt;
&lt;BR /&gt;
and I want to create a new dataset from the above dataset that looks like:&lt;BR /&gt;
&lt;BR /&gt;
age   frequency&lt;BR /&gt;
20      1&lt;BR /&gt;
20      1&lt;BR /&gt;
21      1&lt;BR /&gt;
21      1&lt;BR /&gt;
21      1&lt;BR /&gt;
23      1&lt;BR /&gt;
23      1&lt;BR /&gt;
23      1&lt;BR /&gt;
23      1&lt;BR /&gt;
23      1&lt;BR /&gt;
24      1&lt;BR /&gt;
24      1&lt;BR /&gt;
24      1&lt;BR /&gt;
&lt;BR /&gt;
How can I accomplish this. Thanks.</description>
    <pubDate>Wed, 21 Apr 2010 23:10:30 GMT</pubDate>
    <dc:creator>WAL83</dc:creator>
    <dc:date>2010-04-21T23:10:30Z</dc:date>
    <item>
      <title>Simple Program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-Program/m-p/76101#M16424</link>
      <description>I have a dataset similar to:&lt;BR /&gt;
&lt;BR /&gt;
age   frequency&lt;BR /&gt;
20       2&lt;BR /&gt;
21       3&lt;BR /&gt;
23       5&lt;BR /&gt;
24       3&lt;BR /&gt;
&lt;BR /&gt;
and I want to create a new dataset from the above dataset that looks like:&lt;BR /&gt;
&lt;BR /&gt;
age   frequency&lt;BR /&gt;
20      1&lt;BR /&gt;
20      1&lt;BR /&gt;
21      1&lt;BR /&gt;
21      1&lt;BR /&gt;
21      1&lt;BR /&gt;
23      1&lt;BR /&gt;
23      1&lt;BR /&gt;
23      1&lt;BR /&gt;
23      1&lt;BR /&gt;
23      1&lt;BR /&gt;
24      1&lt;BR /&gt;
24      1&lt;BR /&gt;
24      1&lt;BR /&gt;
&lt;BR /&gt;
How can I accomplish this. Thanks.</description>
      <pubDate>Wed, 21 Apr 2010 23:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-Program/m-p/76101#M16424</guid>
      <dc:creator>WAL83</dc:creator>
      <dc:date>2010-04-21T23:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-Program/m-p/76102#M16425</link>
      <description>Hi:&lt;BR /&gt;
  Inside a DATA step program, you would need to use a DO loop. If you want the value of the FREQUENCY variable to change to 1, then you'd probably need to save the original value within your DATA step logic. Something like this untested code shown below.&lt;BR /&gt;
&lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
DATA new;&lt;BR /&gt;
 . . . more code to read data either with INFILE/INPUT or SET statement . . .&lt;BR /&gt;
 . . . may also want KEEP or DROP statement here . . .&lt;BR /&gt;
           &lt;BR /&gt;
  ** grab original frequency value into new variable name;&lt;BR /&gt;
  orig_frequency = frequency;&lt;BR /&gt;
   &lt;BR /&gt;
  **  set frequency value to 1;&lt;BR /&gt;
  frequency=1;&lt;BR /&gt;
&lt;BR /&gt;
  ** Use original frequency value in do loop for output;&lt;BR /&gt;
  ** control output in DO loop -- one observation will be output;&lt;BR /&gt;
  ** for every iteration of the DO loop.;&lt;BR /&gt;
  do i = 1 to orig_frequency;&lt;BR /&gt;
    output new;&lt;BR /&gt;
  end;&lt;BR /&gt;
. . . more code to end program . . .&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 22 Apr 2010 00:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-Program/m-p/76102#M16425</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-22T00:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-Program/m-p/76103#M16426</link>
      <description>Thanks Cynthia. I'll give it a shot.</description>
      <pubDate>Thu, 22 Apr 2010 13:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-Program/m-p/76103#M16426</guid>
      <dc:creator>WAL83</dc:creator>
      <dc:date>2010-04-22T13:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-Program/m-p/76104#M16427</link>
      <description>Thanks Cynthia. It worked perfectly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
proc import out=data &lt;BR /&gt;
	datafile= "c:\file.xlsx" &lt;BR /&gt;
    dbms=excel replace;&lt;BR /&gt;
    range="Sheet1$"; &lt;BR /&gt;
    getname=yes;&lt;BR /&gt;
    mixed=no;&lt;BR /&gt;
    scantext=yes;&lt;BR /&gt;
    usedate=yes;&lt;BR /&gt;
    scantime=yes;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data data1;&lt;BR /&gt;
	set data;&lt;BR /&gt;
	orig_frequency=frequency;&lt;BR /&gt;
  	frequency=1;&lt;BR /&gt;
  	do i = 1 to orig_frequency;&lt;BR /&gt;
    	output data1;&lt;BR /&gt;
  	end;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 22 Apr 2010 15:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-Program/m-p/76104#M16427</guid>
      <dc:creator>WAL83</dc:creator>
      <dc:date>2010-04-22T15:07:35Z</dc:date>
    </item>
  </channel>
</rss>

