<?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: Compute Net Holdings in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30681#M5862</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am hoping this is a simple question.&amp;nbsp; I followed the advice on this thread to change a row of numbers from + to -.&amp;nbsp; Would you know what is it I am missing on line 47?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;44&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Data ab_2;&lt;/P&gt;&lt;P&gt;45&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set ab;&lt;/P&gt;&lt;P&gt;46&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if AccountType="total saved" then do;&lt;/P&gt;&lt;P&gt;47&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _4Q14=_-2014Q4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; __&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&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;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Jul 2014 21:11:08 GMT</pubDate>
    <dc:creator>jen123</dc:creator>
    <dc:date>2014-07-01T21:11:08Z</dc:date>
    <item>
      <title>Compute Net Holdings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30675#M5856</link>
      <description>Hello,&lt;BR /&gt;
    I am a newbie to SAS and am trying to figure out the best way to solve this problem. I have a data set of option holdings:&lt;BR /&gt;
Name     Action    Quantity     Maturity &lt;BR /&gt;
Joe        Buy           100           Dec 12&lt;BR /&gt;
Joe        Buy           100           Dec 10&lt;BR /&gt;
Joe        Sell             50           Dec 10&lt;BR /&gt;
Mary     Buy             50           Dec 12 &lt;BR /&gt;
&lt;BR /&gt;
I want the result to have net current holdings: &lt;BR /&gt;
Joe        100           Dec 12&lt;BR /&gt;
Joe         50           Dec 10&lt;BR /&gt;
Mary       50           Dec 12 &lt;BR /&gt;
&lt;BR /&gt;
Is there a clean and elegant way to write this?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Sid</description>
      <pubDate>Tue, 09 Nov 2010 05:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30675#M5856</guid>
      <dc:creator>SidS</dc:creator>
      <dc:date>2010-11-09T05:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Compute Net Holdings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30676#M5857</link>
      <description>Hi.&lt;BR /&gt;
You can use ' proc sort nodup; by name descending maturity;run;' to get it.</description>
      <pubDate>Tue, 09 Nov 2010 09:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30676#M5857</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-11-09T09:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Compute Net Holdings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30677#M5858</link>
      <description>You could try something like this:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
/* create a sample data set*/&lt;BR /&gt;
data holdings;&lt;BR /&gt;
 informat maturity date9.;&lt;BR /&gt;
 format maturity date9.;&lt;BR /&gt;
 input name $ action $ quantity maturity;&lt;BR /&gt;
 datalines;&lt;BR /&gt;
Joe Buy 100 12-Dec-2010&lt;BR /&gt;
Joe Buy 100 10-Dec-2010&lt;BR /&gt;
Joe Sell 50 10-Dec-2010&lt;BR /&gt;
Mary Buy 50 12-Dec-2010&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* for Sell transactions, change the sign on the quantity to negative */&lt;BR /&gt;
data holdings2;&lt;BR /&gt;
 set holdings;&lt;BR /&gt;
 if action = "Sell" then do;&lt;BR /&gt;
  quantity = -quantity;&lt;BR /&gt;
 end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* Group the transactions by name and maturity date */&lt;BR /&gt;
proc sort data=holdings2;&lt;BR /&gt;
 by name maturity;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* Add up the transactions for each group */&lt;BR /&gt;
proc means data=holdings2 noprint;&lt;BR /&gt;
 by name maturity;&lt;BR /&gt;
 var quantity;&lt;BR /&gt;
 output out=holdings3 sum=; &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* Print results */&lt;BR /&gt;
proc print data=holdings3 noobs;&lt;BR /&gt;
 var name maturity quantity;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 09 Nov 2010 14:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30677#M5858</guid>
      <dc:creator>Daryl</dc:creator>
      <dc:date>2010-11-09T14:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Compute Net Holdings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30678#M5859</link>
      <description>Hello Sid S,&lt;BR /&gt;
&lt;BR /&gt;
If I correctly understood what you need, the following code produces the result:&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
input Name $ 1-4 Action $ 6-10 Quantity 11-13 Maturity $ 15-20;&lt;BR /&gt;
datalines;&lt;BR /&gt;
Joe   Buy  100 Dec 12&lt;BR /&gt;
Joe   Buy  100 Dec 10&lt;BR /&gt;
Joe   Sell    50 Dec 10&lt;BR /&gt;
Mary Buy   50 Dec 12 &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
/* Add minus sign to quantity for activity=sell */;&lt;BR /&gt;
data a1;&lt;BR /&gt;
  set a;&lt;BR /&gt;
  if UPCASE(Action)="SELL" then quantity=-quantity;&lt;BR /&gt;
run;&lt;BR /&gt;
/* Summarizing Quantity by Name and Maturity */;&lt;BR /&gt;
proc SQL;&lt;BR /&gt;
  create table r as&lt;BR /&gt;
  select Name, SUM(quantity) as Quantity, Maturity&lt;BR /&gt;
  from a1&lt;BR /&gt;
  group by Name, Maturity&lt;BR /&gt;
;quit; &lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 09 Nov 2010 14:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30678#M5859</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-09T14:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Compute Net Holdings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30679#M5860</link>
      <description>Thanks for your help. It really makes it easier to see this implementation using groups. Unfortunately my brain still think in C and that doesn't seem like the right approach for SAS. &lt;BR /&gt;
BTW what is the advantage/disadvantage of using PROC SQL?</description>
      <pubDate>Wed, 10 Nov 2010 00:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30679#M5860</guid>
      <dc:creator>SidS</dc:creator>
      <dc:date>2010-11-10T00:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Compute Net Holdings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30680#M5861</link>
      <description>Hi:&lt;BR /&gt;
  This is one of those apples/oranges questions. It depends on what you're accessing data-wise, how big the tables are, whether you're joining or summarizing or doing sub-queries, etc, etc. You really have to benchmark. Do you want to optimize for I/O operations; for CPU; for ease of maintenance??? &lt;BR /&gt;
 &lt;BR /&gt;
  As a "for-instance", if you need to get both matches and non-matches out of a single join/merge operation, then you can do that in a DATA step program with one program, whereas with SQL you need one join to get the matches and a second join to get the non-matches. &lt;BR /&gt;
 &lt;BR /&gt;
  For a shop that has programmers with a lot of SQL expertise, then PROC SQL is a good entree into using SAS. If a shop has a lot of legacy files (such as sequential mainframe files and/or database files) to read, join, and process, then "regular" DATA step programming might be a better alternative. It all depends. &lt;BR /&gt;
&lt;BR /&gt;
  If you search for user group papers on PROC SQL and DATA step, you will find lots of papers that talk about the pros and cons to PROC SQL versus other SAS approaches.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 10 Nov 2010 02:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30680#M5861</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-10T02:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Compute Net Holdings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30681#M5862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am hoping this is a simple question.&amp;nbsp; I followed the advice on this thread to change a row of numbers from + to -.&amp;nbsp; Would you know what is it I am missing on line 47?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;44&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Data ab_2;&lt;/P&gt;&lt;P&gt;45&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set ab;&lt;/P&gt;&lt;P&gt;46&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if AccountType="total saved" then do;&lt;/P&gt;&lt;P&gt;47&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _4Q14=_-2014Q4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; __&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&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;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 21:11:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-Net-Holdings/m-p/30681#M5862</guid>
      <dc:creator>jen123</dc:creator>
      <dc:date>2014-07-01T21:11:08Z</dc:date>
    </item>
  </channel>
</rss>

