<?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: base sas question in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937265#M45080</link>
    <description>&lt;P&gt;I could envision even more rules than what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;explained. This is clearly not a real-world example, it is so contrived that we can't guess what the real-world usage of this code would be. So we ask questions to help us give better answers.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jul 2024 14:56:00 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-07-26T14:56:00Z</dc:date>
    <item>
      <title>base sas question</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937231#M45070</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data ds;&lt;BR /&gt;Infill datalines;&lt;BR /&gt;Input id name$;&lt;BR /&gt;Cards;&lt;BR /&gt;1 aa&lt;BR /&gt;2 bb&lt;BR /&gt;3 cc&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;required&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output:&lt;BR /&gt;1&amp;nbsp; aa&lt;BR /&gt;1&amp;nbsp; aa&lt;BR /&gt;2&amp;nbsp; bb&lt;BR /&gt;2&amp;nbsp; bb&lt;BR /&gt;2&amp;nbsp; bb&lt;BR /&gt;3&amp;nbsp; cc&lt;BR /&gt;3&amp;nbsp; cc&lt;BR /&gt;3&amp;nbsp; cc&lt;BR /&gt;3&amp;nbsp; cc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please help this .&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 11:59:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937231#M45070</guid>
      <dc:creator>u59166072</dc:creator>
      <dc:date>2024-07-26T11:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: base sas question</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937233#M45071</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set ds;
    if name='aa' then do;
        output; output;
    end;
    else if name='bb' then do;
        output; output; output;
    end;
    else if name='cc' then do;
        output; output; output; output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: in the future, and for this problem as well, it would help if you actually described the problem in words and also described in words the logic that leads to the solution desired.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 12:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937233#M45071</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-26T12:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: base sas question</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937238#M45072</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, thaks for providing answer and is there any other&amp;nbsp; ways to make automate by using macro orelse program in base sas.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 12:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937238#M45072</guid>
      <dc:creator>u59166072</dc:creator>
      <dc:date>2024-07-26T12:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: base sas question</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937240#M45073</link>
      <description>&lt;P&gt;As I said, please explain in words the problem, and please explain in words the logic you want to use to get the final answer. Do not make us guess what logic you want.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 12:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937240#M45073</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-26T12:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: base sas question</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937246#M45075</link>
      <description>ya thank you Paige.</description>
      <pubDate>Fri, 26 Jul 2024 13:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937246#M45075</guid>
      <dc:creator>u59166072</dc:creator>
      <dc:date>2024-07-26T13:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: base sas question</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937248#M45077</link>
      <description>&lt;P&gt;It would be much more helpful if you explained the logic here. We could give you more useful answers then. Specifically, what is the reason aa appears twice and bb appears three times and cc appears 4 times?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 13:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937248#M45077</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-26T13:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: base sas question</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937262#M45079</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393418"&gt;@u59166072&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, thaks for providing answer and is there any other&amp;nbsp; ways to make automate by using macro orelse program in base sas.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS macros generate program code.&lt;/P&gt;
&lt;P&gt;Programs implement rules.&lt;/P&gt;
&lt;P&gt;Without knowing the actual rules examples are insufficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider these two other possible "solutions".&lt;/P&gt;
&lt;P&gt;This one implements a rule of "create one more observation in the output than the numeric value of Id".&lt;/P&gt;
&lt;PRE&gt;/* one more output observation than the value of id*/
data example1;
   set ds;
   output;
   do i= 1 to id;
      output;
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;Looks the same. But is that actually the "rule"? Since many things that use numeric ids could have relatively large numeric values that seems unlikely to be generating 123,456,789 copies of one observation.&lt;/P&gt;
&lt;P&gt;So how about this:&lt;/P&gt;
&lt;P&gt;The rule implemented here is "use the observation (row) number in the source data set and create one more duplicate than number".&lt;/P&gt;
&lt;PRE&gt;/*based on observation number in the data set*/
data example2;
  set ds;
  do i=1 to _n_+1;
     output;
  end;
  drop i ;
run;&lt;/PRE&gt;
&lt;P&gt;That seems like an unlikely need if there are very many observations. That would create a total of (n *(n+1)/2) + n observations where n is the original number of obs in the source data set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; 's solution implements the rule "if the specific value of name is aa then one additional observation, if bb then two additional observations and if cc three additional observations". Nothing else. No other values of Name would result in any output observations. Is that the actual rule?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without clear rules then a solution based on a small example may very well not even come close to providing the desired result for a larger data set.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 14:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937262#M45079</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-26T14:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: base sas question</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937265#M45080</link>
      <description>&lt;P&gt;I could envision even more rules than what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;explained. This is clearly not a real-world example, it is so contrived that we can't guess what the real-world usage of this code would be. So we ask questions to help us give better answers.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 14:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937265#M45080</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-26T14:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: base sas question</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937274#M45081</link>
      <description>&lt;P&gt;Since you're not sure what the problem is, here's my guess.&amp;nbsp; The intent is to output the original observation, then look at ID and output it that many additional times.&amp;nbsp; So the program could be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set ds;
   output;
   do _n_ = 1 to id;
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jul 2024 15:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/base-sas-question/m-p/937274#M45081</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-07-26T15:29:23Z</dc:date>
    </item>
  </channel>
</rss>

