<?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 Partition in Proc SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748217#M234975</link>
    <description>&lt;P&gt;sum(hours_watched) over (partition by user_id, content_title order by calendar_date) AS cumulative_hours,&lt;BR /&gt;____&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN,&lt;BR /&gt;CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can we use partitions inside Proc Sql, if not could you please help me the equivalent logic to use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Jun 2021 20:15:36 GMT</pubDate>
    <dc:creator>david999</dc:creator>
    <dc:date>2021-06-15T20:15:36Z</dc:date>
    <item>
      <title>Partition in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748217#M234975</link>
      <description>&lt;P&gt;sum(hours_watched) over (partition by user_id, content_title order by calendar_date) AS cumulative_hours,&lt;BR /&gt;____&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN,&lt;BR /&gt;CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can we use partitions inside Proc Sql, if not could you please help me the equivalent logic to use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 20:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748217#M234975</guid>
      <dc:creator>david999</dc:creator>
      <dc:date>2021-06-15T20:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Partition in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748220#M234978</link>
      <description>&lt;P&gt;No, you can't use partition in proc sql.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you can try a hash object like this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/td-p/415993" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/Partition-by-equivalent-in-SAS-base-or-proc-sql/td-p/415993&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 20:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748220#M234978</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-06-15T20:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Partition in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748223#M234980</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/241992"&gt;@david999&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;sum(hours_watched) over (partition by user_id, content_title order by calendar_date) AS cumulative_hours,&lt;BR /&gt;____&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN,&lt;BR /&gt;CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we use partitions inside Proc Sql, if not could you please help me the equivalent logic to use?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Almost every flavor of SQL has extensions to the basic idea SQL. SAS is a bit closer to the basic ANSI SQL definitions than most where most of its extensions are in functions available not statement constructs. This could well be that SQL is just one of a host of tools. Many things that some data base systems need to do with their SQL are done by SAS with other procedures or data step code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are connecting to a different data base you can use the local flavor of SQL with PASS THROUGH coding that has the statements executed by the other data base.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 20:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748223#M234980</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-15T20:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Partition in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748251#M234988</link>
      <description>&lt;P&gt;What is your intention?&lt;/P&gt;
&lt;P&gt;Sums for groups can easily be calculated in PROC SUMMARY.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 04:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748251#M234988</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-16T04:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Partition in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748254#M234990</link>
      <description>Hello Kurt,&lt;BR /&gt;&lt;BR /&gt;I'm try to get the cumulative watched hours of the user for a particular show. I'll be using this field (cumulative_watched_hours) in the later part of the code&lt;BR /&gt;&lt;BR /&gt;For eg. if a user X watched two shows A and B for 2hrs and 3 hrs respectively on 13 Apr and again he watched those shows for 5hrs and 6 hrs respectively. Now I'm trying to get watched hours grouped by userid and content title, in the above case the output should look like&lt;BR /&gt;&lt;BR /&gt;Sum user Title&lt;BR /&gt;7 X A&lt;BR /&gt;9 X B</description>
      <pubDate>Wed, 16 Jun 2021 05:58:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748254#M234990</guid>
      <dc:creator>david999</dc:creator>
      <dc:date>2021-06-16T05:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Partition in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748255#M234991</link>
      <description>&lt;P&gt;&lt;EM&gt;Editor's Note: Marking this as accepted. Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;. Also ,the approach described by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; is&amp;nbsp; another way to&amp;nbsp; accumulate the sums.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simple approach, use the SUMMARY procedure:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
class user title;
var hours_watched;
output
  out=want
  sum()=sum
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 14:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748255#M234991</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-17T14:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Partition in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748278#M235008</link>
      <description>&lt;P&gt;Just want to add that SQS SQL is based on ANSI 1992, whereas window functions where added in ANSI 2003.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 08:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748278#M235008</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2021-06-16T08:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Partition in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748348#M235047</link>
      <description>&lt;P&gt;If you want to generate cumulative sums use a retained variable in a data step.&amp;nbsp; Don't bother to try to use SQL for something like that. SQL was not intended to have to process data row-by-row (it operates of SETS).&amp;nbsp; Which is why they had to add that complicated windowing language to describe our to trick SQL to operating on ordered records instead of sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input user $ show  $ date :date. hours;
  format date date9.;
cards;
X A 13APR2021 2
X A 01MAY2021 5
X B 13APR2021 2
Z B 01MAY2021 5
;

data want;
  set have ;
  by user show date;
  if first.show then cum_hours=0;
  cum_hours+hours;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;                                              cum_
Obs    user    show         date    hours    hours

 1      X       A      13APR2021      2        2
 2      X       A      01MAY2021      5        7
 3      X       B      13APR2021      2        2
 4      Z       B      01MAY2021      5        5&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 14:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partition-in-Proc-SQL/m-p/748348#M235047</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-16T14:19:20Z</dc:date>
    </item>
  </channel>
</rss>

