<?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: SAS EG simple query on a calculated field.pls help in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476818#M30958</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input bus_desc $ Exposure;
cards;
marketing 100
marketing 200
sales 300
sales 350
HR 1000
HR 400
;
run;

proc sql;
create table int as select bus_desc, sum(exposure) as exposure
from have group by bus_desc;
create table want as
select
  bus_desc,
  exposure,
  100 * exposure/sum(exposure) as percentage
from int;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 10 Jul 2018 13:57:54 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-07-10T13:57:54Z</dc:date>
    <item>
      <title>SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476791#M30951</link>
      <description>&lt;P&gt;I have to calculate one field where by it will give me percentage of one amount column when compare to the whole amount field and then the final output as a pivot. (refer the attachment of xls pivot .png file attached)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Raw Data&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;bus_desc&lt;/TD&gt;&lt;TD&gt;Exposure&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;marketing&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;marketing&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sales&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sales&lt;/TD&gt;&lt;TD&gt;350&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HR&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HR&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One field computation in xls format with formulae &amp;nbsp;(column name 'Computed_percetange_eachExp_sum' shown for first row)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;bus_desc(A)&lt;/TD&gt;&lt;TD&gt;Exposure (B)&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;Computed_percetange_eachExp_sum&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;marketing&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;(100*B1/SUM(B$1:B$4))&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;marketing&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;8.51&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sales&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;TD&gt;12.77&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sales&lt;/TD&gt;&lt;TD&gt;350&lt;/TD&gt;&lt;TD&gt;14.89&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HR&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;TD&gt;42.55&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HR&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;17.02&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and finally the output required in SAS EG (output computed in xls pivot option&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="final pivot table in xls.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21693i37F12865996E9CE2/image-size/large?v=v2&amp;amp;px=999" role="button" title="final pivot table in xls.png" alt="final pivot table in xls.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 13:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476791#M30951</guid>
      <dc:creator>Tajinder</dc:creator>
      <dc:date>2018-07-10T13:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476818#M30958</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input bus_desc $ Exposure;
cards;
marketing 100
marketing 200
sales 300
sales 350
HR 1000
HR 400
;
run;

proc sql;
create table int as select bus_desc, sum(exposure) as exposure
from have group by bus_desc;
create table want as
select
  bus_desc,
  exposure,
  100 * exposure/sum(exposure) as percentage
from int;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jul 2018 13:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476818#M30958</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-10T13:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476830#M30959</link>
      <description>&lt;P&gt;Your pivot table results doesn't match what actually result. Actual results are:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 365px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21697i4A6398383F616424/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input bus_desc :$20. Exposure;
datalines;
marketing 100
marketing 200
sales 300
sales 350
HR 1000
HR 400
;
run;


proc sql;
create table compute1 as
select 1 as group,bus_desc,Exposure,(100*Exposure/sum(Exposure)) as Computed_percetange_eachExp_sum
from have
group by 1;
run;

proc sql;
create table comp2(drop=row) as 
select *,(Sum_Exp/(select sum(Exposure) from have))*100 as Sum_Pct
		from (select monotonic() as row,bus_desc,sum(Exposure) as Sum_Exp
					from Compute1
						group by 2
				union 
				select monotonic()+10 as row,'Grand Total' as bus_desc,sum(Exposure) as Sum_Exp
					from Compute1
					)

order by 1
;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 14:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476830#M30959</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-07-10T14:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476842#M30961</link>
      <description>&lt;P&gt;Note that you can implement both of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s SQL queries using the Query Builder in Enterprise Guide. No need to use SAS code.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 15:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476842#M30961</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-07-10T15:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476987#M30975</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15142"&gt;@TomKari&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Note that you can implement both of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s SQL queries using the Query Builder in Enterprise Guide. No need to use SAS code.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Absolutely. But it took me less time to write that code than I would have needed in the Query Builder.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 06:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/476987#M30975</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-11T06:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477049#M30978</link>
      <description>&lt;P&gt;Yes,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;. I'm often amused that it takes next to no time to type out the SAS code to solve a problem, but to describe how to do something with the EG point-and-click facilities takes FOREVER!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 12:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477049#M30978</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-07-11T12:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477050#M30979</link>
      <description>&lt;P&gt;Thanks however I am working on EG and require EG screenshots or steps. Below is the code which can help in Base SAS..&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 12:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477050#M30979</guid>
      <dc:creator>Tajinder</dc:creator>
      <dc:date>2018-07-11T12:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477061#M30980</link>
      <description>&lt;P&gt;You have to build two queries in succession, just as I did in my code.&lt;/P&gt;
&lt;P&gt;In the first, select both columns, and apply a SUM to exposure; bus_desc will be automatically used as group.&lt;/P&gt;
&lt;P&gt;Build another query on the result of the first query, where you select both columns resulting from query #1, and add a computed column. Select advanced for that column, and enter the formula for the percentage (use the correct variable name for the column created in the first step). De-select automatically created groups, and you're done.&lt;/P&gt;
&lt;P&gt;All that's left is some prettying up (proper column names etc.).&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 13:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477061#M30980</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-11T13:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477063#M30981</link>
      <description>&lt;P&gt;If you are comfortable with SAS EG tool, can &amp;nbsp;you pls send the screenshots..it will be of great help&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 13:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477063#M30981</guid>
      <dc:creator>Tajinder</dc:creator>
      <dc:date>2018-07-11T13:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG simple query on a calculated field.pls help</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477375#M31003</link>
      <description>&lt;P&gt;Hi friends.. thank you for your support... Anyways I cracked it&amp;nbsp;on my own. It was very easy and need not have to write some codes..&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 09:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-simple-query-on-a-calculated-field-pls-help/m-p/477375#M31003</guid>
      <dc:creator>Tajinder</dc:creator>
      <dc:date>2018-07-12T09:24:18Z</dc:date>
    </item>
  </channel>
</rss>

