<?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 order or operations -proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/order-or-operations-proc-sql/m-p/862294#M340592</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I know that in proc sql there are rules of&amp;nbsp; order of operations:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From---Where-----Select&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in this case first go to data set "Have"&lt;/P&gt;
&lt;P&gt;Then perform row filter (obs=1) so it take only first row&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it perform the select activities.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;My question:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Since we&amp;nbsp; asked to take only one row,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then how the operations in select that working on all observations will work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select 'TOTAL' as Category,
(select count(*) as nr_customers from have),
1 as PCT_Customers,
(select sum(wealth) as Sum_Wealth from have),&lt;BR /&gt;1 as Pct_Wealth
&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;from have(obs=1);&lt;/FONT&gt;&lt;/STRONG&gt;
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>Sat, 04 Mar 2023 16:18:02 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2023-03-04T16:18:02Z</dc:date>
    <item>
      <title>order or operations -proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/order-or-operations-proc-sql/m-p/862294#M340592</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I know that in proc sql there are rules of&amp;nbsp; order of operations:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From---Where-----Select&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in this case first go to data set "Have"&lt;/P&gt;
&lt;P&gt;Then perform row filter (obs=1) so it take only first row&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it perform the select activities.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;My question:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Since we&amp;nbsp; asked to take only one row,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then how the operations in select that working on all observations will work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select 'TOTAL' as Category,
(select count(*) as nr_customers from have),
1 as PCT_Customers,
(select sum(wealth) as Sum_Wealth from have),&lt;BR /&gt;1 as Pct_Wealth
&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;from have(obs=1);&lt;/FONT&gt;&lt;/STRONG&gt;
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>Sat, 04 Mar 2023 16:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/order-or-operations-proc-sql/m-p/862294#M340592</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-03-04T16:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: order or operations -proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/order-or-operations-proc-sql/m-p/862296#M340594</link>
      <description>&lt;P&gt;Because the summations are done in the sub-selects, where all observations are read.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 16:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/order-or-operations-proc-sql/m-p/862296#M340594</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-04T16:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: order or operations -proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/order-or-operations-proc-sql/m-p/862298#M340596</link>
      <description>&lt;P&gt;How about describing what you are attempting to do with example data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or try removing the (OBS=1) and see the result. In this case I am pretty sure that the given code will yield NN number of identical records where NN is the number of observations in the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL does not have any standard order of using records so I am not sure what you are asking about in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;(select count(*) as nr_customers from have)&lt;/LI-CODE&gt;
&lt;P&gt;Will not create a variable nr_customers but a generated name like _TEMA002. If you want the result to be named nr_customers the syntax is&lt;/P&gt;
&lt;PRE&gt;(select count(*) from have) as nr_customers&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 16:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/order-or-operations-proc-sql/m-p/862298#M340596</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-04T16:30:38Z</dc:date>
    </item>
  </channel>
</rss>

