<?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: tabulate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/tabulate/m-p/61846#M13461</link>
    <description>Peter,&lt;BR /&gt;
 I tried this ad it worked:&lt;BR /&gt;
table correct_name='Physician'*city='City'*state='State'*zip1='Zip'*Ghtm='GHTM',                &lt;BR /&gt;
             ship_date=' '*(both='Total (mg)'*sum=' ' nordi='% Nordi'*pctsum&lt;BOTH&gt;=' '*F=7.1)&lt;BR /&gt;
			  all=' '*(both='Annual Total (mg)'*sum=' '*F=7.)&lt;BR /&gt;
             / rts=33;      &lt;BR /&gt;
&lt;BR /&gt;
Now I need to work on the dsceding order by the total!&lt;/BOTH&gt;</description>
    <pubDate>Wed, 05 Aug 2009 21:28:14 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2009-08-05T21:28:14Z</dc:date>
    <item>
      <title>tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate/m-p/61843#M13458</link>
      <description>proc tabulate data=master_cvv1 format=5.;                                      &lt;BR /&gt;
   class correct_name city state zip1 ghtm;                                           &lt;BR /&gt;
   class ship_date / descending;                                             &lt;BR /&gt;
   var compete nordi both;                                              &lt;BR /&gt;
   table correct_name='Physician'*city='City'*state='State'*zip1='Zip'*Ghtm='GHTM',           &lt;BR /&gt;
            ship_date=' '*(both='Total (mg)'*sum=' ' nordi='% Nordi'*pctsum&lt;BOTH&gt;=' '*F=7.1)&lt;BR /&gt;
             / rts=33;                                                     &lt;BR /&gt;
   format ship_date yyq6.;                                                   &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
For the above code I will have the columns as below:&lt;BR /&gt;
                                                 2009Q2                 2009Q1&lt;BR /&gt;
Physician City State GHTM   Total(mg)  %Nordi       Total(mg)  %Nordi&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
How to get the a new column Total which is sum of total(mg) of 2009Q2 and 2009Q1 and display the report in the desceding order of the Total?&lt;BR /&gt;
Thanks,&lt;BR /&gt;
SASPhile&lt;/BOTH&gt;</description>
      <pubDate>Wed, 05 Aug 2009 19:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate/m-p/61843#M13458</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-08-05T19:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate/m-p/61844#M13459</link>
      <description>The ALL statistic can provide total over the SHIP_DATEs at&lt;BR /&gt;
    ( ship_date=' '*(both='Total (mg)'*sum=' ' nordi='% Nordi'*pctsum&lt;BOTH&gt;=' '*F=7.1&lt;BR /&gt;
     ALL='2009H1'* both='Total (mg)'*sum=' ' )&lt;BR /&gt;
however, order is more of a problem.&lt;BR /&gt;
There is a proc statement option "order= data" that might help, but you would have to prepare the total of both quarters and apply to each, before sorting the data.&lt;BR /&gt;
I'm not certain that that would work.&lt;BR /&gt;
A first try: sort into order for totalling BOTH[pre] proc sort data= master_cvv1 out= prep1 ;&lt;BR /&gt;
  by correct_name city state zip1 Ghtm ;&lt;BR /&gt;
run ;[/pre]  * now a double pass, first to get the total across all ship_date (i.e. within GHTM ) ;&lt;BR /&gt;
 * second to output the data with the exta column=Tboth= total of "both" within GHTM;[pre]data prep2 ;&lt;BR /&gt;
  set prep1(in= first ) prep1( in= second ) ;&lt;BR /&gt;
  by correct_name city state zip1 Ghtm ;&lt;BR /&gt;
  if first.ghtm then  tboth=0  ;&lt;BR /&gt;
  if first then tboth + both ;&lt;BR /&gt;
  if second then output ;&lt;BR /&gt;
run ;[/pre]* finally sort into the output order and hope it "sticks" ;[pre]proc sort out= prep3 ;&lt;BR /&gt;
  by correct_name city state zip1 Ghtm &lt;BR /&gt;
       descending tboth ;&lt;BR /&gt;
run ;[/pre]then run your tabulatelike[pre]proc tabulate data= prep3 format= 5. order=data ;[/pre]&lt;BR /&gt;
and let us know how it goes&lt;BR /&gt;
 &lt;BR /&gt;
PeterC&lt;/BOTH&gt;</description>
      <pubDate>Wed, 05 Aug 2009 20:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate/m-p/61844#M13459</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-08-05T20:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate/m-p/61845#M13460</link>
      <description>Peter,&lt;BR /&gt;
 I tried the code but it wouldnt give the total of all the quaters.&lt;BR /&gt;
2009Q2	                                                2009Q1		&lt;BR /&gt;
Total (mg)	% Nordi	TOTAL	   Total (mg)    % Nordi	  TOTAL&lt;BR /&gt;
					  &lt;BR /&gt;
25056	9.4	25056	       20798	            12.6	   20798&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
But the idea is to create this way: &lt;BR /&gt;
&lt;BR /&gt;
total= 25056+20798&lt;BR /&gt;
&lt;BR /&gt;
        2009Q2                          2009Q1                                      Total&lt;BR /&gt;
Total (mg)	   % Nordi               Total (mg)	  % Nordi&lt;BR /&gt;
25056	     9.4                     20798	 12.6                       45854</description>
      <pubDate>Wed, 05 Aug 2009 21:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate/m-p/61845#M13460</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-08-05T21:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate/m-p/61846#M13461</link>
      <description>Peter,&lt;BR /&gt;
 I tried this ad it worked:&lt;BR /&gt;
table correct_name='Physician'*city='City'*state='State'*zip1='Zip'*Ghtm='GHTM',                &lt;BR /&gt;
             ship_date=' '*(both='Total (mg)'*sum=' ' nordi='% Nordi'*pctsum&lt;BOTH&gt;=' '*F=7.1)&lt;BR /&gt;
			  all=' '*(both='Annual Total (mg)'*sum=' '*F=7.)&lt;BR /&gt;
             / rts=33;      &lt;BR /&gt;
&lt;BR /&gt;
Now I need to work on the dsceding order by the total!&lt;/BOTH&gt;</description>
      <pubDate>Wed, 05 Aug 2009 21:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate/m-p/61846#M13461</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-08-05T21:28:14Z</dc:date>
    </item>
  </channel>
</rss>

