<?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: Case Statement equivalents in CASL in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Case-Statement-equivalents-in-CASL/m-p/439732#M140</link>
    <description>&lt;P&gt;Thank you! I did use Fed SQL to carry out the summarization (and we lose nothing from proc sql there)&amp;nbsp;; I was trying to see if&amp;nbsp;the options provided by CASL fulfill almost everything we do in SQL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example - in the SAS Viya Data Studio&amp;nbsp;custom code window, one can either code in data steps or CASL.&amp;nbsp; Not ideal, (irritating, rather :)) , but just want to make sure we are covered in such situations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The use of the IF , along with the simple.summary actionsets does do most of what a case when statement does. I just want to be extra sure about a count distinct + CASE WHEN situation though (count(distinct case when...) - let me attempt something and get back&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Feb 2018 15:33:51 GMT</pubDate>
    <dc:creator>SundareshS</dc:creator>
    <dc:date>2018-02-23T15:33:51Z</dc:date>
    <item>
      <title>Case Statement equivalents in CASL</title>
      <link>https://communities.sas.com/t5/Developers/Case-Statement-equivalents-in-CASL/m-p/437976#M138</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to rewrite various Proc SQL like queries in CAS and have relied on the simple action set for most of them. Perhaps I am missing this in the documentation / examples, but can anyone help me understand how to write a CASE WHEN condition ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example would be the code below - I count the number of&amp;nbsp;distinct players per team in the&amp;nbsp;BASEBALL dataset. But what if I need to count only those players who have nruns &amp;gt; X ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sundar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="font-size: 12.0pt; font-family: Consolas; color: #020202;"&gt;/* &lt;A href="http://documentation.sas.com/?cdcId=vdmmlcdc&amp;amp;cdcVersion=8.11&amp;amp;docsetId=casanpg&amp;amp;docsetTarget=p119l8ejshp7gjn157ttba5rpmuc.htm&amp;amp;locale=en"&gt;http://documentation.sas.com/?cdcId=vdmmlcdc&amp;amp;cdcVersion=8.11&amp;amp;docsetId=casanpg&amp;amp;docsetTarget=p119l8ejshp7gjn157ttba5rpmuc.htm&amp;amp;locale=en&lt;/A&gt; */&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc cas;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; session mysession;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; simple.distinct /&amp;nbsp; &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inputs={"Name"}&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table={&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="baseball",&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; groupBy={"TEAM"}&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; casout={&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="bb_summary",&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; replace=True&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table.save /&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; /*3*/&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table={name="bb_summary"}&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="bb_summary.sashdat"&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; replace=True&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;BR /&gt;
run;&lt;BR /&gt;
quit;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 14:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Case-Statement-equivalents-in-CASL/m-p/437976#M138</guid>
      <dc:creator>SundareshS</dc:creator>
      <dc:date>2018-02-16T14:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Case Statement equivalents in CASL</title>
      <link>https://communities.sas.com/t5/Developers/Case-Statement-equivalents-in-CASL/m-p/438664#M139</link>
      <description>&lt;P&gt;If you want something even more like PROC SQL, FedSQL is CAS compatible and can be accessed via PROC FEDSQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since we're going with action sets, I believe that the intent of developers was to follow through with SAS norms and not SQL norms. The SAS syntax norm is use of the IF/THEN statement, which performs the same functions as a CASE/WHEN in SQL. You should be able to see some use of it in &lt;A href="http://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=proccas&amp;amp;docsetTarget=n0xg6e5kdefl8dn1bmuls185rte8.htm&amp;amp;locale=en" target="_self"&gt;this example&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some not-real&amp;nbsp;and not-working&amp;nbsp;code here to simplify the examples in the above documentation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC CAS;
     IF (nvar &amp;gt; X) THEN RETURN(X);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not well-versed in CAS action sets yet, but hopefully this helps point you in the right direction!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 15:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Case-Statement-equivalents-in-CASL/m-p/438664#M139</guid>
      <dc:creator>GinaRepole</dc:creator>
      <dc:date>2018-02-20T15:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Case Statement equivalents in CASL</title>
      <link>https://communities.sas.com/t5/Developers/Case-Statement-equivalents-in-CASL/m-p/439732#M140</link>
      <description>&lt;P&gt;Thank you! I did use Fed SQL to carry out the summarization (and we lose nothing from proc sql there)&amp;nbsp;; I was trying to see if&amp;nbsp;the options provided by CASL fulfill almost everything we do in SQL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example - in the SAS Viya Data Studio&amp;nbsp;custom code window, one can either code in data steps or CASL.&amp;nbsp; Not ideal, (irritating, rather :)) , but just want to make sure we are covered in such situations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The use of the IF , along with the simple.summary actionsets does do most of what a case when statement does. I just want to be extra sure about a count distinct + CASE WHEN situation though (count(distinct case when...) - let me attempt something and get back&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 15:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Case-Statement-equivalents-in-CASL/m-p/439732#M140</guid>
      <dc:creator>SundareshS</dc:creator>
      <dc:date>2018-02-23T15:33:51Z</dc:date>
    </item>
  </channel>
</rss>

