<?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: How to generate N rows based on a value in a column? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644270#M192425</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ N_OBS;
length obs_id $ 16;
if n_obs&amp;gt;0 then do i=1 to n_obs;
obs_id=cat('obs',i);
output;
end;

drop i n_obs;
cards;
01 0
02 1
03 3
04 2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 30 Apr 2020 15:02:48 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-04-30T15:02:48Z</dc:date>
    <item>
      <title>How to generate N rows based on a value in a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644266#M192423</link>
      <description>&lt;P&gt;I am trying to create a new dataset based on an existing dataset.&lt;/P&gt;&lt;P&gt;My data contains a unique ID and number of observations (N_OBS) for each unique ID, as shown in the code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
input ID $ N_OBS;
cards;
01 0
02 1
03 3
04 2
;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a row for each unique value connected to the ID, so if ID='03' has 3 observations in N_OBS, i would like 3 rows with the ID '03' counting the number of observations OBS1-OBS3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The end result i am looking for would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want;&lt;BR /&gt;input ID $ OBS_ID $;
cards;
02 OBS1
03 OBS1
03 OBS2
03 OBS3
04 OBS1
04 OBS2
;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am uncertain how to approach this problem, and tips/help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 14:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644266#M192423</guid>
      <dc:creator>SteinOk</dc:creator>
      <dc:date>2020-04-30T14:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate N rows based on a value in a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644270#M192425</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ N_OBS;
length obs_id $ 16;
if n_obs&amp;gt;0 then do i=1 to n_obs;
obs_id=cat('obs',i);
output;
end;

drop i n_obs;
cards;
01 0
02 1
03 3
04 2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Apr 2020 15:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644270#M192425</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-30T15:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate N rows based on a value in a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644274#M192429</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I may have spent too much time on this forum.&amp;nbsp; My initial idea for a solution varied by exactly 2 characters from yours, basically style choices.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 15:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644274#M192429</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-30T15:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate N rows based on a value in a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644275#M192430</link>
      <description>Thank you, i am very pleased i was able to learn something new about how SAS handles if statements.</description>
      <pubDate>Thu, 30 Apr 2020 15:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644275#M192430</guid>
      <dc:creator>SteinOk</dc:creator>
      <dc:date>2020-04-30T15:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate N rows based on a value in a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644276#M192431</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I may have spent too much time on this forum.&amp;nbsp; My initial idea for a solution varied by exactly 2 characters from yours, basically style choices.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Alternative explanation: great minds think alike.&lt;/P&gt;
&lt;P&gt;Alternative explanation 2: birds of a feather flock together&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 15:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-N-rows-based-on-a-value-in-a-column/m-p/644276#M192431</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-30T15:20:30Z</dc:date>
    </item>
  </channel>
</rss>

