<?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: &amp;quot;case when&amp;quot; in sql &amp;quot;then 1 else 0 end as&amp;quot; &amp;lt;-- what does this syntax mean? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quot-case-when-quot-in-sql-quot-then-1-else-0-end-as-quot-lt/m-p/407883#M99430</link>
    <description>&lt;P&gt;Your understanding is correct. As for the dates, quoting a date and then following it with a d converts the date to a SAS date, namely the number of days since January 1, 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;case statements, by definition, end with an end statement, followed by the variable name the selected/comuted values are assigned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2017 01:11:53 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-10-27T01:11:53Z</dc:date>
    <item>
      <title>"case when" in sql "then 1 else 0 end as" &lt;-- what does this syntax mean?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-case-when-quot-in-sql-quot-then-1-else-0-end-as-quot-lt/m-p/407881#M99429</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below was prefaced by&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let startdate = '01JAN1999'd;
%let elig_2010 = '31DEC2010'd;
....&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Question 1 of 2: For above, why is there a 'd' after the date? Is this how data is typically stored?&lt;/P&gt;&lt;P&gt;Question 2 of 2: For below, I think its saying when&amp;nbsp;svcdate &amp;gt;= 01JAN1999 but svcdate &amp;lt;= 31DEC2010, then do the&amp;nbsp;subsequent thing.&amp;nbsp;&lt;STRONG&gt;But I don't understand what "then 1 else 0 end as test_2010" means.&amp;nbsp;&lt;/STRONG&gt;Does that mean make the variable test_2010 into 1 if true, else not? Why is there an "end"?&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;proc sql; 
	create table hbsag_lab (rename=(enrolid=patient_id)) as
	select distinct enrolid, svcdate,
	case when &amp;amp;startdate. &amp;lt;=svcdate &amp;lt;= &amp;amp;elig_2010. then 1 else 0 end as test_2010

from clean_dataset (where=(lab_test=1));

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2017 00:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-case-when-quot-in-sql-quot-then-1-else-0-end-as-quot-lt/m-p/407881#M99429</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2017-10-27T00:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: "case when" in sql "then 1 else 0 end as" &lt;-- what does this syntax mean?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-case-when-quot-in-sql-quot-then-1-else-0-end-as-quot-lt/m-p/407883#M99430</link>
      <description>&lt;P&gt;Your understanding is correct. As for the dates, quoting a date and then following it with a d converts the date to a SAS date, namely the number of days since January 1, 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;case statements, by definition, end with an end statement, followed by the variable name the selected/comuted values are assigned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 01:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-case-when-quot-in-sql-quot-then-1-else-0-end-as-quot-lt/m-p/407883#M99430</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-10-27T01:11:53Z</dc:date>
    </item>
  </channel>
</rss>

