<?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: proc sql to Join three tables and calculate percentages in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-to-Join-three-tables-and-calculate-percentages/m-p/341689#M63295</link>
    <description>&lt;P&gt;From your example I do not see Test3 contributing anything. So what would be the purpose of "merging" test 3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or did you miss stating the you want to select the records from test and test1 to only include matches for test3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And similarly everything in test is also in test1. So why bother with test at all?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also your data step for test1&amp;nbsp;does not work correctly because the variables product and&amp;nbsp;call_type (which should be character and and not indicated as such) will have&amp;nbsp;the length, not specified,&amp;nbsp;default to 8 characters. Also since you are using list input call_type will only have the first word when you want "Scheduled appointment".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should also specify exactly what the numerator and denominator is for each of those percentages as it makes little sense as it is not obvious. &lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;AND&lt;/STRONG&gt; your result seems to have changed the regions for some names. The data shows Donald in Chicago and Mary in Bridgeport.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2017 17:32:42 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-03-16T17:32:42Z</dc:date>
    <item>
      <title>proc sql to Join three tables and calculate percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-to-Join-three-tables-and-calculate-percentages/m-p/341389#M63292</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need help in joining three tables using proc SQL and then calculate percentages for some variables. Any help on this is greatly appreciated. My three tables look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;infile&amp;nbsp;datalines;&lt;/P&gt;&lt;P&gt;input ID &amp;nbsp;Region$ &amp;nbsp;Name$ &amp;nbsp;Tier$ product$;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;101 &amp;nbsp;Albany &amp;nbsp;Chris &amp;nbsp;A &amp;nbsp; Furniture&lt;/P&gt;&lt;P&gt;102 &amp;nbsp;Chicago &amp;nbsp;Donald &amp;nbsp;A &amp;nbsp;Furniture&lt;/P&gt;&lt;P&gt;103 &amp;nbsp;Trenton &amp;nbsp; Sam &amp;nbsp; &amp;nbsp; &amp;nbsp;B &amp;nbsp; Furniture&lt;/P&gt;&lt;P&gt;104 &amp;nbsp;Philadelphia &amp;nbsp;Rose &amp;nbsp;C &amp;nbsp;Furniture&lt;/P&gt;&lt;P&gt;105 &amp;nbsp;Bridgeport &amp;nbsp; Mary &amp;nbsp; D &amp;nbsp; Furniture&lt;/P&gt;&lt;P&gt;101 Santafe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Suzanne B &amp;nbsp;Furniture&lt;/P&gt;&lt;P&gt;105 Utah &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;King &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp;Furniture&lt;/P&gt;&lt;P&gt;106 &amp;nbsp;Syracuse &amp;nbsp;Queen &amp;nbsp;B &amp;nbsp; &amp;nbsp;Furniture&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data &amp;nbsp;test1;&lt;/P&gt;&lt;P&gt;infile&amp;nbsp;datalines;&lt;/P&gt;&lt;P&gt;input ID &amp;nbsp;Region$ &amp;nbsp;Name$ &amp;nbsp;Tier$ product$ &amp;nbsp;calls &amp;nbsp; call_type;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;101 &amp;nbsp;Albany &amp;nbsp;Chris &amp;nbsp;A &amp;nbsp; Furniture &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10 &amp;nbsp; &amp;nbsp; Detail&lt;/P&gt;&lt;P&gt;102 &amp;nbsp;Chicago &amp;nbsp;Donald &amp;nbsp;A &amp;nbsp;Furniture &amp;nbsp; &amp;nbsp; &amp;nbsp;12 &amp;nbsp; Webex&lt;/P&gt;&lt;P&gt;103 &amp;nbsp;Trenton &amp;nbsp; Sam &amp;nbsp; &amp;nbsp; &amp;nbsp;B &amp;nbsp; Furniture &amp;nbsp; &amp;nbsp; &amp;nbsp;13 &amp;nbsp;Detail&lt;/P&gt;&lt;P&gt;104 &amp;nbsp;Philadelphia &amp;nbsp;Rose &amp;nbsp;C &amp;nbsp;Furniture &amp;nbsp; 13 &amp;nbsp; Scheduled appointment&lt;/P&gt;&lt;P&gt;105 &amp;nbsp;Bridgeport &amp;nbsp; Mary &amp;nbsp; D &amp;nbsp; Furniture &amp;nbsp; 12 &amp;nbsp; Detail&lt;/P&gt;&lt;P&gt;101&amp;nbsp;Santafe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Suzanne B &amp;nbsp;Furniture &amp;nbsp; 14 &amp;nbsp;Webex&lt;/P&gt;&lt;P&gt;105 Utah &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;King &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp;Furniture &amp;nbsp; &amp;nbsp; 10 &amp;nbsp; Webex&lt;/P&gt;&lt;P&gt;106 &amp;nbsp;Syracuse &amp;nbsp;Queen &amp;nbsp;B &amp;nbsp; &amp;nbsp;Furniture &amp;nbsp; &amp;nbsp; &amp;nbsp;12 &amp;nbsp;Scheduled appointment&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data test3;&lt;/P&gt;&lt;P&gt;infile&amp;nbsp;datalines;&lt;/P&gt;&lt;P&gt;input ID &amp;nbsp;Region$ &amp;nbsp;Name$ ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;101 &amp;nbsp;Albany &amp;nbsp;Chris &amp;nbsp;&lt;/P&gt;&lt;P&gt;102 &amp;nbsp;Chicago &amp;nbsp;Donald &amp;nbsp;&lt;/P&gt;&lt;P&gt;103 &amp;nbsp;Trenton &amp;nbsp; Sam &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;104 &amp;nbsp;Philadelphia &amp;nbsp;Rose &amp;nbsp;&lt;/P&gt;&lt;P&gt;105 &amp;nbsp;Bridgeport &amp;nbsp; Mary &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;101&amp;nbsp;Santa Fe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Suzanne&amp;nbsp;&lt;/P&gt;&lt;P&gt;105 Utah &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;King &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;106 &amp;nbsp;Syracuse &amp;nbsp;Queen &amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So table 1 have only product information, table 2 have a number of calls for each product and table3 have region IDs and the person's names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to combine all the datasets using proc SQL and calculate % of calls for each tier (A, B, C only) and the % frequency of all the calls and also call types (Detail, Webex, scheduled appointment). I need the following columns in the final output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Region&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Name&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;%Calls&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;%frequency&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Detail&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Webex&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Scheduled appointment&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;101&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Albany&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;67.0%&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;25.0%&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;10&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;10&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;12&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;102&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Trenton&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Donald&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;50.0%&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;30.0%&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;12&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;11&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;13&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;103&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Santafe&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Mary&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;45.0%&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;35.0%&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;13&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;12&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;11&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are just the rough numbers not the actual ones after calculation, this is just for sample output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 01:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-to-Join-three-tables-and-calculate-percentages/m-p/341389#M63292</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2017-03-16T01:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql to Join three tables and calculate percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-to-Join-three-tables-and-calculate-percentages/m-p/341396#M63293</link>
      <description>&lt;P&gt;Since we probably don't want to do all of your work, what have you tried and where specifically are you running into problems.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 02:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-to-Join-three-tables-and-calculate-percentages/m-p/341396#M63293</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-16T02:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql to Join three tables and calculate percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-to-Join-three-tables-and-calculate-percentages/m-p/341479#M63294</link>
      <description>&lt;P&gt;A) Why are you fixed with SQL?&lt;/P&gt;
&lt;P&gt;B)&amp;nbsp;It's generally not a good idea to store percentages. Have this calculated&amp;nbsp;in a report step instead, like in PROC TABULATE/REPORT. Or in a semantic layer, if you have one.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 08:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-to-Join-three-tables-and-calculate-percentages/m-p/341479#M63294</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-03-16T08:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql to Join three tables and calculate percentages</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-to-Join-three-tables-and-calculate-percentages/m-p/341689#M63295</link>
      <description>&lt;P&gt;From your example I do not see Test3 contributing anything. So what would be the purpose of "merging" test 3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or did you miss stating the you want to select the records from test and test1 to only include matches for test3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And similarly everything in test is also in test1. So why bother with test at all?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also your data step for test1&amp;nbsp;does not work correctly because the variables product and&amp;nbsp;call_type (which should be character and and not indicated as such) will have&amp;nbsp;the length, not specified,&amp;nbsp;default to 8 characters. Also since you are using list input call_type will only have the first word when you want "Scheduled appointment".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should also specify exactly what the numerator and denominator is for each of those percentages as it makes little sense as it is not obvious. &lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;AND&lt;/STRONG&gt; your result seems to have changed the regions for some names. The data shows Donald in Chicago and Mary in Bridgeport.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 17:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-to-Join-three-tables-and-calculate-percentages/m-p/341689#M63295</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-16T17:32:42Z</dc:date>
    </item>
  </channel>
</rss>

