<?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: two dimensional report  with 2 varaibles in y and one in X in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/two-dimensional-report-with-2-varaibles-in-y-and-one-in-X/m-p/616867#M180681</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use &lt;STRONG&gt;options missing='0';&lt;/STRONG&gt; as a global statement to put 0 instead of dots.&lt;/P&gt;
&lt;P&gt;The &lt;STRONG&gt;ALL keyword in the table statement&lt;/STRONG&gt; will allow you to display total in row / in columns according to the class variables (see. example below).&lt;/P&gt;
&lt;P&gt;Regarding question #2, neither PROC TABULATE nor PROC REPORT will allow you to order on a statistic or calculated analysis variable. As far as I know, the only way to do this is to create an ordering variable, and then force PROC REPORT to show the data according to this variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Options missing='0';
proc tabulate data=rawtbl;
	class team model LenghtLoan/order=sum;
	var SUMLOAN interest;
	table team all, ((model)*(LenghtLoan all)) * (n SUMLOAN*sum interest*mean);
	table team all, ((LenghtLoan)*(model all)) * (n SUMLOAN*sum interest*mean);
	weight SUMLOAN;
	format LenghtLoan LenghtLoan.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Jan 2020 10:51:06 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-01-13T10:51:06Z</dc:date>
    <item>
      <title>two dimensional report  with 2 varaibles in y and one in X</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-dimensional-report-with-2-varaibles-in-y-and-one-in-X/m-p/616843#M180664</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I need to create a summary report that will look like that:&lt;/P&gt;
&lt;P&gt;The raw data table contains following fields:&lt;/P&gt;
&lt;P&gt;Customer ID, Model,Team,SUMLOAN ,interest, LenghtLoan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a summary report that will look like that:&lt;/P&gt;
&lt;P&gt;In x dimension will have categories of&amp;nbsp; field TEAM (There are 3 categories:&amp;nbsp; X/Y/W).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Y dimension will have categories of Model field (2 possible categories : A/B) and under it categories of field&amp;nbsp; LenghtLoan&lt;/P&gt;
&lt;P&gt;(2 possible categories :above 365 / below 365).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need to calculated 3 fields:&lt;/P&gt;
&lt;P&gt;N_records&lt;/P&gt;
&lt;P&gt;SUM OF SUMLOAN&amp;nbsp;&lt;/P&gt;
&lt;P&gt;weighted average of interest&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want also to include TOTAL Row&amp;nbsp; in the report&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data  rawtbl;
INFILE DATALINES DLM=',';
input ID MODEL $ Team $	SUMLOAN	interest LenghtLoan;
cards;
1,A,W,10,2.4,180
2,A,Y,20,2.3,180
4,A,X,40,7.8,720
9,A,X,90,4.1,3650
10,A,Y,100,5.2,180
11,A,X,110,4.8,180
12,A,W,120,2.7,720
18,A,X,180,2.9,3650
19,A,Y,190,4.1,3650
20,A,W,200,3.9,3650
3,B,X,30,3.4,180
5,B,Y,50,8.1,720
6,B,X,60,2.5,3650
7,B,X,70,2.6,3650
8,B,X,80,2.7,3650
13,B,X,130,2.8,720
14,B,W,140,3.9,720
15,B,X,150,9.6,180
16,B,Y,160,8.3,180
17,B,X,170,4.7,3650
;
run;

/*Required output:*/
/*in x dimension will have categories of :TEAM(X/Y/W)*/
/*in Y dimension will have categories of :Model(A/B) and under it categories of LenghtLoan(above 365 / below 365);*/
/*Need to calucltaed: N_records ,SUM OF SUMLOAN , weighted avarage of interest*/



 proc summary data=rawtbl(where=(Model='A' and LenghtLoan&amp;lt;365)) nway ;
    class Team;
    var interest/weight=SUMLOAN;
    var SUMLOAN;
    output out=ModelA_Less1Year (drop=_type_ _freq_)
           mean(interest)=Weighted_Avg_interest
           n(SUMLOAN)=n_loan 
           sum(SUMLOAN)=SUMLOAN;
run;

 proc summary data=rawtbl(where=(Model='A' and LenghtLoan&amp;gt;=365)) nway ;
    class Team;
    var interest/weight=SUMLOAN;
    var SUMLOAN;
    output out=ModelA_More1Year (drop=_type_ _freq_)
           mean(interest)=Weighted_Avg_interest
           n(SUMLOAN)=n_loan 
           sum(SUMLOAN)=SUMLOAN;
run;


 proc summary data=rawtbl(where=(Model='B' and LenghtLoan&amp;lt;365)) nway ;
    class Team;
    var interest/weight=SUMLOAN;
    var SUMLOAN;
    output out=ModelB_Less1Year (drop=_type_ _freq_)
           mean(interest)=Weighted_Avg_interest
           n(SUMLOAN)=n_loan 
           sum(SUMLOAN)=SUMLOAN;
run;

 proc summary data=rawtbl(where=(Model='B' and LenghtLoan&amp;gt;=365)) nway ;
    class Team;
    var interest/weight=SUMLOAN;
    var SUMLOAN;
    output out=ModelB_More1Year (drop=_type_ _freq_)
           mean(interest)=Weighted_Avg_interest
           n(SUMLOAN)=n_loan 
           sum(SUMLOAN)=SUMLOAN;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 07:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-dimensional-report-with-2-varaibles-in-y-and-one-in-X/m-p/616843#M180664</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-01-13T07:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: two dimensional report  with 2 varaibles in y and one in X</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-dimensional-report-with-2-varaibles-in-y-and-one-in-X/m-p/616853#M180670</link>
      <description>&lt;P&gt;/*UNTESTED CODE*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc format;
	value LenghtLoan
			low-365 = "Below 365"
			365-high = "Above 365";	
run;

proc tabulate data=rawtbl;
	class team model LenghtLoan;
	var SUMLOAN interest;
	table team, (model*LenghtLoan) * (n SUMLOAN*sum interest*mean) ;
	weight SUMLOAN;
	format LenghtLoan LenghtLoan.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Are you sure you want the sum of sumloan?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 09:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-dimensional-report-with-2-varaibles-in-y-and-one-in-X/m-p/616853#M180670</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-13T09:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: two dimensional report  with 2 varaibles in y and one in X</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-dimensional-report-with-2-varaibles-in-y-and-one-in-X/m-p/616861#M180676</link>
      <description>&lt;P&gt;Thank you. It is perfect.&lt;/P&gt;
&lt;P&gt;Sum of SumLoan summarize the sum of loans .&lt;/P&gt;
&lt;P&gt;I have some more questions please:&lt;/P&gt;
&lt;P&gt;1-Replace Null values (dot symbol) with 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2- Order of Rows by&amp;nbsp; sum Of SumLoans for all models&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3- Add&amp;nbsp; another Raw with totals data information&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4-Create calculations (3 columns)&amp;nbsp; for Model A (All lenghts)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5-Create calculations (3 columns)&amp;nbsp; for Model B (All lenghts)&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;6- Create calculations (3 columns)&amp;nbsp; for Below365 (All Models)&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;7-Create calculations (3 columns)&amp;nbsp; for Above365 (All Models)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;8-Create calculations (3 columns)&amp;nbsp; for&amp;nbsp; All&lt;/P&gt;
&lt;P&gt;So now the required table will be much wider&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 10:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-dimensional-report-with-2-varaibles-in-y-and-one-in-X/m-p/616861#M180676</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-01-13T10:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: two dimensional report  with 2 varaibles in y and one in X</title>
      <link>https://communities.sas.com/t5/SAS-Programming/two-dimensional-report-with-2-varaibles-in-y-and-one-in-X/m-p/616867#M180681</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use &lt;STRONG&gt;options missing='0';&lt;/STRONG&gt; as a global statement to put 0 instead of dots.&lt;/P&gt;
&lt;P&gt;The &lt;STRONG&gt;ALL keyword in the table statement&lt;/STRONG&gt; will allow you to display total in row / in columns according to the class variables (see. example below).&lt;/P&gt;
&lt;P&gt;Regarding question #2, neither PROC TABULATE nor PROC REPORT will allow you to order on a statistic or calculated analysis variable. As far as I know, the only way to do this is to create an ordering variable, and then force PROC REPORT to show the data according to this variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Options missing='0';
proc tabulate data=rawtbl;
	class team model LenghtLoan/order=sum;
	var SUMLOAN interest;
	table team all, ((model)*(LenghtLoan all)) * (n SUMLOAN*sum interest*mean);
	table team all, ((LenghtLoan)*(model all)) * (n SUMLOAN*sum interest*mean);
	weight SUMLOAN;
	format LenghtLoan LenghtLoan.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jan 2020 10:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/two-dimensional-report-with-2-varaibles-in-y-and-one-in-X/m-p/616867#M180681</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-13T10:51:06Z</dc:date>
    </item>
  </channel>
</rss>

