<?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: Need help with views and select statements in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777565#M31466</link>
    <description>&lt;P&gt;Hi, I would need to find the total of all quantity and divide this by the total of all the 4 stock columns to get the percentage&lt;/P&gt;</description>
    <pubDate>Sun, 31 Oct 2021 10:42:55 GMT</pubDate>
    <dc:creator>don_dadda</dc:creator>
    <dc:date>2021-10-31T10:42:55Z</dc:date>
    <item>
      <title>Need help with views and select statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777561#M31463</link>
      <description>&lt;DIV class=""&gt;&lt;P&gt;I have three tables, columns in brackets:&lt;BR /&gt;Orders (product_id quantity)&lt;BR /&gt;Products (product_id name)&lt;BR /&gt;Stock (product_id uk us eu amea)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These have been imported into SAS Studio and I now need to create a VIEW called ‘top_three’ that shows the stock levels for the top&lt;BR /&gt;three selling products (by volume, not value). The VIEW should contain the following&lt;BR /&gt;fields:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;name (from the product table)&lt;/LI&gt;&lt;LI&gt;A field totalling the volume of sales called ‘number_of_sales’&lt;/LI&gt;&lt;LI&gt;The four stock level fields: eu, us, uk and amea&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;(b) alter the script to add a field to the view for 1. (a) that shows the total sales as a&lt;BR /&gt;percentage of total stock. Call this field ‘sale_stock_percentage’&lt;/P&gt;&lt;P&gt;this is the code I have so far:&lt;/P&gt;&lt;PRE&gt;create view top_three_stock as
select a.name,
b.quantity,
c.uk,
c.eu,
c.us,
c.amea
from work.product a
full join work.stock c
on a.product_id = c.product_id
full join work.orders b
on a.product_id = b.product_id
;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 31 Oct 2021 09:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777561#M31463</guid>
      <dc:creator>don_dadda</dc:creator>
      <dc:date>2021-10-31T09:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with views and select statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777564#M31465</link>
      <description>&lt;P&gt;Explain what formula would be used for SALE_STOCK_PERCENTAGE. Show us what you have tried for SALE_STOCK_PERCENTAGE.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 10:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777564#M31465</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-31T10:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with views and select statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777565#M31466</link>
      <description>&lt;P&gt;Hi, I would need to find the total of all quantity and divide this by the total of all the 4 stock columns to get the percentage&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 10:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777565#M31466</guid>
      <dc:creator>don_dadda</dc:creator>
      <dc:date>2021-10-31T10:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with views and select statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777566#M31467</link>
      <description>&lt;P&gt;Show us what you have tried for SALE_STOCK_PERCENTAGE.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 10:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777566#M31467</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-31T10:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with views and select statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777567#M31468</link>
      <description>&lt;P&gt;I havent tried anything as of yet, here is where I have got to:&lt;/P&gt;&lt;PRE&gt;create table join1 as
select a.name, 
b.quantity,
c.uk, 
c.eu, 
c.us, 
c.amea
from work.product a
full join work.stock c
on a.product_id = c.product_id
full join work.order_product b
on a.product_id = b.product_id
;

create table sort1 as
select distinct name, sum(quantity) as number_of_sales, uk, us, eu, amea
from join1
group by name
order by number_of_sales desc
;

proc sql outlobs=3;
create view top_three as
select name, number_of_sales
from sort1;&lt;/PRE&gt;&lt;P&gt;my last piece isnt working as I would expect, it is listing all rows rather than just the top 3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not know how to alter the view.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 10:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777567#M31468</guid>
      <dc:creator>don_dadda</dc:creator>
      <dc:date>2021-10-31T10:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with views and select statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777571#M31469</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql outlobs=3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your log should show an error on this command. That's what you need to fix.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 11:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-with-views-and-select-statements/m-p/777571#M31469</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-31T11:50:07Z</dc:date>
    </item>
  </channel>
</rss>

