<?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: Reverse function of group by in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99680#M20976</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="400"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="180"&gt;Medication&lt;/TD&gt;&lt;TD class="xl63" width="93"&gt;NDC&lt;/TD&gt;&lt;TD class="xl63" width="57"&gt;RX Count&lt;/TD&gt;&lt;TD class="xl63" width="70"&gt;Total QTY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;Abilify 10mg Tablet&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;24236027902&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;Abilify 10mg Tablet&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;59148000813&lt;/TD&gt;&lt;TD align="right"&gt;257&lt;/TD&gt;&lt;TD align="right"&gt;2297&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;Abilify 15mg Tablet&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;59148000913&lt;/TD&gt;&lt;TD align="right"&gt;19&lt;/TD&gt;&lt;TD align="right"&gt;217.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;Abilify 20mg Tablet&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;59148001013&lt;/TD&gt;&lt;TD align="right"&gt;441&lt;/TD&gt;&lt;TD align="right"&gt;8145.5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Andreas,&lt;/P&gt;&lt;P&gt;Thanks, that was helpful.&lt;/P&gt;&lt;P&gt;But that code will fail when the case is as above. Rx count need not be 1 always.&lt;/P&gt;&lt;P&gt;Let me explain. In line 2 (10mg Tablet) i need 257 identical lines as output, however Total qty in output should be 8.93 (i.e 2297 / 257)&lt;/P&gt;&lt;P&gt;How do we crack this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;+Sathyan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Dec 2012 11:34:36 GMT</pubDate>
    <dc:creator>skallamp</dc:creator>
    <dc:date>2012-12-14T11:34:36Z</dc:date>
    <item>
      <title>Reverse function of group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99675#M20971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a particular scenario where I wanted to get the reverse of group by function.&lt;/P&gt;&lt;P&gt;Here is the sample data&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; Table 1&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="435"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" width="110"&gt;medication&lt;/TD&gt;&lt;TD class="xl63" style="border-left: medium none;" width="84"&gt;ndc&lt;/TD&gt;&lt;TD class="xl63" style="border-left: medium none;" width="119"&gt;rx_count&lt;/TD&gt;&lt;TD class="xl63" style="border-left: medium none;" width="122"&gt;total_qty&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;-1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;-10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl64" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;If I do the summary using the below code&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="426"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="426"&gt;PROC SQL;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&amp;nbsp;&amp;nbsp; CREATE TABLE WORK.QUERY_FOR_TESTTEST AS &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&amp;nbsp;&amp;nbsp; SELECT t1.medication, &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.ndc, &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (SUM(t1.rx_count)) FORMAT=BEST12. AS SUM_of_rx_count, &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (SUM(t1.total_qty)) FORMAT=BEST12. AS SUM_of_total_qty&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM WORK.TESTTEST AS t1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GROUP BY t1.medication, t1.ndc;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;QUIT;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt; I get the result as below.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table 2&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="444"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="119"&gt;medication&lt;/TD&gt;&lt;TD class="xl65" style="border-left: medium none;" width="84"&gt;ndc&lt;/TD&gt;&lt;TD class="xl65" style="border-left: medium none;" width="119"&gt;SUM_of_rx_count&lt;/TD&gt;&lt;TD class="xl65" style="border-left: medium none;" width="122"&gt;SUM_of_total_qty&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="20" style="border-top: medium none;"&gt;Lipitor&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none; border-top: medium none;"&gt;59148000813&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-left: medium none; border-top: medium none;"&gt;10&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-left: medium none; border-top: medium none;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way that I get the Table 1 as out put from table 2. Table 2 is the aggregated data, what I want is the extended as table 1.&lt;/P&gt;&lt;P&gt;What would be the query I should use?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;+Sathyan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 05:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99675#M20971</guid>
      <dc:creator>skallamp</dc:creator>
      <dc:date>2012-12-14T05:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse function of group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99676#M20972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want add this aggregated data at the bottom of Table1 ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 426px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;" width="426"&gt;PROC SQL;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CREATE TABLE WORK.QUERY_FOR_TESTTEST AS &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from WORK.TESTTEST&lt;/P&gt;&lt;P&gt;union all corr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;"&gt;&amp;nbsp;&amp;nbsp; SELECT t1.medication, &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.ndc, &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (SUM(t1.rx_count)) FORMAT=BEST12. AS SUM_of_rx_count, &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (SUM(t1.total_qty)) FORMAT=BEST12. AS SUM_of_total_qty&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM WORK.TESTTEST AS t1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GROUP BY t1.medication, t1.ndc;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;"&gt;QUIT;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 08:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99676#M20972</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-12-14T08:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse function of group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99677#M20973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not want to add the result at the bottom.&lt;/P&gt;&lt;P&gt;What I want is, how do we derive the table 1 detailed information from table 2 summary? I am OK if we do not get the negative values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 09:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99677#M20973</guid>
      <dc:creator>skallamp</dc:creator>
      <dc:date>2012-12-14T09:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse function of group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99678#M20974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just join the two tables using the group by columns as join key.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 09:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99678#M20974</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2012-12-14T09:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse function of group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99679#M20975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;skallamp wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
javascript:void(0);
&lt;P&gt;I do not want to add the result at the bottom.&lt;/P&gt;
&lt;P&gt;What I want is, how do we derive the table 1 detailed information from table 2 summary? I am OK if we do not get the negative values.&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Possible only if "total_qty" is constant for all obs in one group and no negative values are present. With a least one negative total_qty/rx_count the number of "restored" observations won't match the number of obs in the original dataset. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; work.faked_original;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; work.QUERY_FOR_TESTTEST;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; rx_count total_qty i &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;8&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; sum_of_: i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; i = &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; sum_of_rx_count;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rx_count = &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; total_qty = sum_of_total_qty / sum_of_rx_count;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 09:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99679#M20975</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2012-12-14T09:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse function of group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99680#M20976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="400"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="180"&gt;Medication&lt;/TD&gt;&lt;TD class="xl63" width="93"&gt;NDC&lt;/TD&gt;&lt;TD class="xl63" width="57"&gt;RX Count&lt;/TD&gt;&lt;TD class="xl63" width="70"&gt;Total QTY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;Abilify 10mg Tablet&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;24236027902&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;Abilify 10mg Tablet&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;59148000813&lt;/TD&gt;&lt;TD align="right"&gt;257&lt;/TD&gt;&lt;TD align="right"&gt;2297&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;Abilify 15mg Tablet&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;59148000913&lt;/TD&gt;&lt;TD align="right"&gt;19&lt;/TD&gt;&lt;TD align="right"&gt;217.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;Abilify 20mg Tablet&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;59148001013&lt;/TD&gt;&lt;TD align="right"&gt;441&lt;/TD&gt;&lt;TD align="right"&gt;8145.5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Andreas,&lt;/P&gt;&lt;P&gt;Thanks, that was helpful.&lt;/P&gt;&lt;P&gt;But that code will fail when the case is as above. Rx count need not be 1 always.&lt;/P&gt;&lt;P&gt;Let me explain. In line 2 (10mg Tablet) i need 257 identical lines as output, however Total qty in output should be 8.93 (i.e 2297 / 257)&lt;/P&gt;&lt;P&gt;How do we crack this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;+Sathyan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 11:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99680#M20976</guid>
      <dc:creator>skallamp</dc:creator>
      <dc:date>2012-12-14T11:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse function of group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99681#M20977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will have to set up a few more rules about how to do it.&amp;nbsp; Once you allow that negative numbers could have been part of the unsummarized table, there are an infinite number of solutions to the problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 13:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99681#M20977</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-12-14T13:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse function of group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99682#M20978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;Is that really what you want?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Medication $ @&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; NDC $ @&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;33&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; sRX_Count @&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;37&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; sTotal_QTY;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;datalines&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;Abilify 10mg Tablet 24236027902 1&amp;nbsp;&amp;nbsp; 30 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;Abilify 10mg Tablet 59148000813 257 2297 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;Abilify 15mg Tablet 59148000913 19&amp;nbsp; 217.5 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;Abilify 20mg Tablet 59148001013 441 8145.5 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; want(keep=Medication NDC RX_Count Total_QTY) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;itx=int(sTotal_QTY/sRX_Count);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; count=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; itx;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;Total_QTY=sTotal_QTY/sRX_Count;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;RX_Count=sRX_Count/itx;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 15:06:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reverse-function-of-group-by/m-p/99682#M20978</guid>
      <dc:creator>joehinson</dc:creator>
      <dc:date>2012-12-14T15:06:52Z</dc:date>
    </item>
  </channel>
</rss>

