<?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 Calculating percentages from 2 different tables SAS EG in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634696#M35716</link>
    <description>&lt;P&gt;Morning Lads,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I wanted to ask an urgent question about calculating percentages from 2 different tables. In the first picture you see the total measurements per month/section.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AK100_5-1585134768181.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37347i62A792654D324802/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AK100_5-1585134768181.png" alt="AK100_5-1585134768181.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the second picture you see a the total measurements per MatType per month per section.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AK100_6-1585134831835.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37348iC44B4466180A34ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AK100_6-1585134831835.png" alt="AK100_6-1585134831835.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to calculate the percentages of subtotal/total in a new table but if I join the tables i get the wrong totals. So I actually want 21 (from second table) / 112 (from first table) and 6 (from second table) / 52 (from first table).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that I use the query builders most of the time instead of coding (also note that these are just screenshots, the tables are much much bigger.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Mar 2020 11:17:11 GMT</pubDate>
    <dc:creator>AK100</dc:creator>
    <dc:date>2020-03-25T11:17:11Z</dc:date>
    <item>
      <title>Calculating percentages from 2 different tables SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634696#M35716</link>
      <description>&lt;P&gt;Morning Lads,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I wanted to ask an urgent question about calculating percentages from 2 different tables. In the first picture you see the total measurements per month/section.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AK100_5-1585134768181.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37347i62A792654D324802/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AK100_5-1585134768181.png" alt="AK100_5-1585134768181.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the second picture you see a the total measurements per MatType per month per section.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AK100_6-1585134831835.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37348iC44B4466180A34ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AK100_6-1585134831835.png" alt="AK100_6-1585134831835.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to calculate the percentages of subtotal/total in a new table but if I join the tables i get the wrong totals. So I actually want 21 (from second table) / 112 (from first table) and 6 (from second table) / 52 (from first table).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that I use the query builders most of the time instead of coding (also note that these are just screenshots, the tables are much much bigger.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 11:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634696#M35716</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-03-25T11:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentages from 2 different tables SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634702#M35717</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Now I want to calculate the percentages of subtotal/total in a new table but if I join the tables i get the wrong totals.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What is wrong when you do this? How are you doing it?&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So I actually want 21 (from second table) / 112 (from first table) &lt;FONT color="#FF0000"&gt;and 6 (from second table) / 52 (from first table)&lt;/FONT&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't understand the part in red.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 11:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634702#M35717</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-25T11:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentages from 2 different tables SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634706#M35718</link>
      <description>&lt;P&gt;As I told you in our private conversation, you need to deliver usable example data. And what you expect to get out of it.&lt;/P&gt;
&lt;P&gt;Expand this for table 1:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
input sectie $ maand2 :date9. totaal;
format maand2 yymon7.;
datalines;
2632CT 01jul2019 112
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and provide a similar step for table 2. It is not rocket science, and it helps you learn basic data step technique, which is essential for further progress in using SAS to its fullest.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 11:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634706#M35718</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-25T11:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentages from 2 different tables SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634709#M35719</link>
      <description>hi Paige Miller,&lt;BR /&gt;&lt;BR /&gt;Right now I'am joining the 2 tables together and make 1 table out of it, but that gives me the wrong totals. Which means the percentages are wrong to. After the join there is no distinction There is no distiction between SECTIE anymore so all the totals of JULY turn out to be 112, august turn out to be 161. This, while every month has 2 totals (because of 2 different SECTIE's)&lt;BR /&gt;&lt;BR /&gt;Dbout the red part: 21 is DDM (subtotal, SECTIE 2632CT) from the second table that has to be dived by 112 from the first table (the total).&lt;BR /&gt;6 is DDZ (subtotal, SECTIE 2646BT) from the second table which has to be dived by 52 from the first table (the total). This has to be done for all of them of course, i just picked 2 random. Hope it clear like this?</description>
      <pubDate>Wed, 25 Mar 2020 11:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634709#M35719</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-03-25T11:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentages from 2 different tables SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634715#M35720</link>
      <description>Hi Kurt,&lt;BR /&gt;&lt;BR /&gt;I would love to learn that of course on your way, and I will code it in the coming days and let you know how it looks. However, I though maybe someone had a short solution for now because I need the output for work.</description>
      <pubDate>Wed, 25 Mar 2020 12:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634715#M35720</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-03-25T12:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentages from 2 different tables SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634724#M35721</link>
      <description>&lt;P&gt;See this example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
input sectie $ maand :date9. totaal;
format maand yymon7.;
datalines;
2632CT 01jul2019 112
;

data table2;
input sectie $ maand2 :date9. subtotaal mattype $;
format maand2 yymon7.;
datalines;
2632CT 01jul2019 22 DDM
;

proc sql;
create table want as
select
  t1.sectie,
  t1.maand,
  t2.subtotaal,
  t2.subtotaal / t1.totaal as percentage format=percent7.2
from table1 t1, table2 t2
where t1.sectie = t2.sectie and t1.maand = t2.maand2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2020 12:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-percentages-from-2-different-tables-SAS-EG/m-p/634724#M35721</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-25T12:29:16Z</dc:date>
    </item>
  </channel>
</rss>

