<?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: ERROR in &amp;quot;case&amp;quot; proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738975#M230584</link>
    <description>Thank you, Kurt, I see ! &lt;BR /&gt;</description>
    <pubDate>Tue, 04 May 2021 15:52:09 GMT</pubDate>
    <dc:creator>SASdevAnneMarie</dc:creator>
    <dc:date>2021-05-04T15:52:09Z</dc:date>
    <item>
      <title>ERROR in "case" proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738950#M230569</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't resolve the error in "case" of proc sql. My code seems to be correct :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mois=10;
%let jour=10;
%let annee_20=2020;
%let annee_21=2021;

proc sql;
    create table Prestations_RT as
    select distinct
        is_contrat,
        datepart(d_eff_sin)        as date_sinistre            format  = ddmmyy10.,
        year(datepart(d_bilan))    as annee_bilan,
        sum(mt_brut_prest * (cd_dossier = "DCASS"))        as Mt_DC,
        sum(mt_brut_prest * (cd_dossier = "DCCCS"))        as Mt_DC_rentes,
        sum(mt_brut_prest * (cd_dossier = "RT"))        as Mt_RT,
        sum(mt_brut_prest * (cd_dossier = "RTCCS"))        as Mt_RT_rentes,
        Case
            when (mdy(01,01,2020) &amp;lt;= datepart(date_sinistre) &amp;lt;= mdy(&amp;amp;mois.,&amp;amp;jour.,&amp;amp;annee_20.) then "T1_2020")
            when (mdy(01,01,2021) &amp;lt;= datepart(date_sinistre) &amp;lt;= mdy(&amp;amp;mois.,&amp;amp;jour.,&amp;amp;annee_21.) then "T1_2021")
        end                                                as Trimestre
    from Table
    where /*substr(is_contrat,1,4) in &amp;amp;Liste_produits.
    and */(mdy(01,01,2020) &amp;lt; (datepart(date_sinistre)) &amp;lt; mdy(&amp;amp;mois..,&amp;amp;jour.,&amp;amp;annee_20.))
    and (mdy(01,01,2021) &amp;lt; (datepart(date_sinistre)) &amp;lt; mdy(&amp;amp;mois.,&amp;amp;jour.,&amp;amp;annee_21.))
    group by
        is_contrat,
        year(datepart(d_bilan));
quit;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have this error all time, I don't know why.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarieT_0-1620141734078.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59010i9AC85081510B4D31/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarieT_0-1620141734078.png" alt="MarieT_0-1620141734078.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I attached the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help !&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 15:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738950#M230569</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-05-04T15:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR in "case" proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738955#M230573</link>
      <description>&lt;P&gt;Just remove the unnecessary parentheses:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;when mdy(01,01,2020) &amp;lt;= datepart(date_sinistre) &amp;lt;= mdy(&amp;amp;mois.,&amp;amp;jour.,&amp;amp;annee_20.) then "T1_2020"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The way you wrote it, the "then" was still part of the condition.&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 15:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738955#M230573</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-04T15:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR in "case" proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738957#M230575</link>
      <description>&lt;P&gt;PS since we're talking SAS here, provide data as &lt;EM&gt;SAS datasets&lt;/EM&gt;, not Excel spreadsheets.&lt;/P&gt;
&lt;P&gt;Datasets are posted in code as data steps with datalines.&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 15:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738957#M230575</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-04T15:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR in "case" proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738975#M230584</link>
      <description>Thank you, Kurt, I see ! &lt;BR /&gt;</description>
      <pubDate>Tue, 04 May 2021 15:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738975#M230584</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-05-04T15:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR in "case" proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738976#M230585</link>
      <description>That works !&lt;BR /&gt;Thank you !</description>
      <pubDate>Tue, 04 May 2021 15:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-in-quot-case-quot-proc-sql/m-p/738976#M230585</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-05-04T15:52:31Z</dc:date>
    </item>
  </channel>
</rss>

