<?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: Pivot table percentages in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109888#M30524</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you're counting people, how many are in type 1, how many are in type 1 and type 2?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that sound accurate?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Feb 2013 17:55:00 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-02-14T17:55:00Z</dc:date>
    <item>
      <title>Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109886#M30522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a sample of my data which describes several different types of accounts a customer has:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id Type1 Type2 Type3 Type4 Type5;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 2 0 0 0 0&lt;/P&gt;&lt;P&gt;2 3 1 0 0 0&lt;/P&gt;&lt;P&gt;3 1 1 1 1 1&lt;/P&gt;&lt;P&gt;4 0 0 0 0 1&lt;/P&gt;&lt;P&gt;5 0 0 2 2 0&lt;/P&gt;&lt;P&gt;6 0 0 0 1 1&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 448px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" width="64"&gt;Table&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;Type1&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;Type2&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;Type3&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;Type4&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;Type5&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;Total&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Type1&lt;/TD&gt;&lt;TD class="xl66"&gt;3&lt;/TD&gt;&lt;TD class="xl66"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Type2&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;0&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Type3&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;0&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Type4&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Type5&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;0&lt;/TD&gt;&lt;TD class="xl65"&gt;0&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Total&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on where to start?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 16:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109886#M30522</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-02-14T16:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109887#M30523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; I don't understand where the percentages come in. It looks like you're counting...but I am confused by WHAT you are counting and why you have TYPE1-TYPE5 in both the ROWs and the COLUMNs of your output. Do you want an output REPORT, an output DATASET??? or??? SAS can only make pivot tables in a few ways, so if you want an Excel pivot table from your SAS dataset, do you have the SAS Add-in for Microsoft Office or are you using ODS TAGSETS.TABLEEDITOR to make your pivot table from an HTML file?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; What code have you tried?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 17:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109887#M30523</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2013-02-14T17:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109888#M30524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you're counting people, how many are in type 1, how many are in type 1 and type 2?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that sound accurate?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 17:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109888#M30524</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-02-14T17:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109889#M30525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the confusion...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The percentages would be the cell value / 6.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not tied to it being a pivot table, I just didn't know what else to call it.&amp;nbsp; I'm trying to find an easy way to answer questions like "how many customers who have a type1 product also have a type2"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 19:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109889#M30525</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-02-14T19:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109890#M30526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;questions like "how many customers who have type1 products also have type2"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 19:45:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109890#M30526</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-02-14T19:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109891#M30527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Again, I'm confused by your data and your desired results. How did you get 3 for the total of Type1 going down to the final row??? I see 3+2+1+1 = 7 and Type 1 going across, I see 3+2+1+1...again, you show 3 in the Total column, How did you derive 3 in either location?&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 02:06:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109891#M30527</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2013-02-15T02:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109892#M30528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am not taking your observation values since they seems to be not useful..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;input id Type1 Type2 Type3 Type4 Type5;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 * 0 0 0 0&lt;/P&gt;&lt;P&gt;2 * * 0 0 0&lt;/P&gt;&lt;P&gt;3 * *&amp;nbsp; *&amp;nbsp; * *&lt;/P&gt;&lt;P&gt;4 0 0 0 0 *&lt;/P&gt;&lt;P&gt;5 0 0 * * 0&lt;/P&gt;&lt;P&gt;6 0 0 0 * *&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;'&lt;/P&gt;&lt;P&gt;My interpretation for your desired ouput ...first ROW&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="448"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" style="border: 0px solid black;" width="64"&gt;Table&lt;/TD&gt;&lt;TD style="border: 0px solid black;" width="64"&gt;Type1&lt;/TD&gt;&lt;TD style="border: 0px solid black;" width="64"&gt;Type2&lt;/TD&gt;&lt;TD style="border: 0px solid black;" width="64"&gt;Type3&lt;/TD&gt;&lt;TD style="border: 0px solid black;" width="64"&gt;Type4&lt;/TD&gt;&lt;TD style="border: 0px solid black;" width="64"&gt;Type5&lt;/TD&gt;&lt;TD style="border: 0px solid black;" width="64"&gt;Total&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20" style="border: 0px solid black;"&gt;Type1&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;3&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;2&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;1&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;1&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;0&lt;/TD&gt;&lt;TD style="border: 0px solid black;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;number investors in type1 only ................3&lt;/P&gt;&lt;P&gt;number investors in type1 and type2.........2&lt;/P&gt;&lt;P&gt;number investors in type1 and type3.........1&lt;/P&gt;&lt;P&gt;number investors in type1 and type4.........1&lt;/P&gt;&lt;P&gt;number investors in type1 and type5.........0&lt;STRONG&gt;............(should be 1);..&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;why it is displaying as '0' in desired output?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Regards&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ALLU&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 04:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109892#M30528</guid>
      <dc:creator>allurai0412</dc:creator>
      <dc:date>2013-02-15T04:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109893#M30529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This gets you started, but its not efficient by any means &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;.&lt;/P&gt;&lt;P&gt;Also, if combinations are missing they will be missing in the transposed table. You can fix that by creating a table with all combinations and merging it if required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id Type1 Type2 Type3 Type4 Type5;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 2 0 0 0 0&lt;/P&gt;&lt;P&gt;2 3 1 0 0 0&lt;/P&gt;&lt;P&gt;3 1 1 1 1 1&lt;/P&gt;&lt;P&gt;4 0 0 0 0 1&lt;/P&gt;&lt;P&gt;5 0 0 2 2 0&lt;/P&gt;&lt;P&gt;6 0 0 0 1 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array type(5) type1-type5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do t=1 to 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if type(t) &amp;gt;0 then output;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop type1-type5;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Generate master table;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table master_blank as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct t1.t, t2.t as t_cross, 0 as count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have2 t1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cross join (select distinct t from have2) t2;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table counted as &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select t, t_cross, count(distinct id) as count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from fill&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by t, t_cross;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=counted out=counted2 prefix=type;&lt;/P&gt;&lt;P&gt;var count;&lt;/P&gt;&lt;P&gt;by t;&lt;/P&gt;&lt;P&gt;id t_cross;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 15:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109893#M30529</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-02-15T15:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109894#M30530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="246082" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;First, some comments. From your previous posts, I can tell you are an experienced SAS programmer, so I don't expect that your question can be addressed easily. From my limited knowledge, I believe it would be a lot easier if you have access to OLAP Cube Studio, if not, given the potential matrix calculation involved, even IML can do a easier job than just BASE SAS. The following code is only a preliminary attempt of producing the exact result you were asking.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id Type1 Type2 Type3 Type4 Type5;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 2 0 0 0 0&lt;/P&gt;&lt;P&gt;2 3 1 0 0 0&lt;/P&gt;&lt;P&gt;3 1 1 1 1 1&lt;/P&gt;&lt;P&gt;4 0 0 0 0 1&lt;/P&gt;&lt;P&gt;5 0 0 2 2 0&lt;/P&gt;&lt;P&gt;6 0 0 0 1 1&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select cats(nobs) into :idct from dictionary.tables where libname='WORK' AND MEMNAME='HAVE';&lt;/P&gt;&lt;P&gt;&amp;nbsp; select cats(NVAR-1) into :varct from dictionary.tables where libname='WORK' AND MEMNAME='HAVE';quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;length Table $5.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have end=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array t(&amp;amp;idct,&amp;amp;varct) _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array tot(%eval(&amp;amp;varct+1)) _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array type type1-type&amp;amp;varct;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do j=1 to &amp;amp;varct;&lt;/P&gt;&lt;P&gt;&amp;nbsp; t(id,j)=ifn(type(j)&amp;gt;0,1,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do j=1 to &amp;amp;varct;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing (of type(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp; table=vname(type(j));&lt;/P&gt;&lt;P&gt;do k=1 to &amp;amp;varct;&lt;/P&gt;&lt;P&gt;do i=1 to &amp;amp;idct;&lt;/P&gt;&lt;P&gt;&amp;nbsp; type(k)=sum(type(k),t(i,j)*t(i,k));&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;Total=type(j);&lt;/P&gt;&lt;P&gt;&amp;nbsp; tot(j)=type(j);&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;if last and j &amp;gt; &amp;amp;varct then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to &amp;amp;varct;&lt;/P&gt;&lt;P&gt;type(i)=tot(i);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;table='Total';&lt;/P&gt;&lt;P&gt;total=&amp;amp;idct;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop id i k j;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 18:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109894#M30530</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-02-15T18:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109895#M30531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for looking again.&amp;nbsp; The cells are not mutually exclusive, so you can't add down rows or across columns.&amp;nbsp; There are a total of 6 customers, three of whom have Type1 products.&amp;nbsp; So the row total for type1 is 3 (as is the column total for type 1).&amp;nbsp; There are two customers who have both Type1 products and Type2 products (intersection of Type1 and Type2 =2). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The row/column totals are the number of customers having at least one product of that type.&amp;nbsp; The intersections represent the number of customers having at least of one of both types.&amp;nbsp; So the value represented by (x,y) would be the number of customers having products of type x and type y.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that makes more sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 13:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109895#M30531</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-02-19T13:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109896#M30532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're right..based on the input data, there is one customer having both Type1 and Type5 products.&amp;nbsp; I've updated the table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 13:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pivot-table-percentages/m-p/109896#M30532</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-02-19T13:37:30Z</dc:date>
    </item>
  </channel>
</rss>

