<?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 SAS SQL - CASE STATEMENT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348214#M80611</link>
    <description>&lt;P&gt;Hi, I'm using a case else statement to try to create a new variable (source_flag) to fill in for blank for the first_source variable, however it is not populating the new variable definition of 'unknown' when it runs. &amp;nbsp;Any help would be greately appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table d02_buyer_source_recency as&lt;BR /&gt;select DISTINCT email_id,&lt;BR /&gt;/* first source */&lt;BR /&gt;first_source,&lt;BR /&gt;first_available_source,&lt;BR /&gt;CASE when (first_source = ' ' OR first_source = '.') then 'UNKNOWN'&lt;BR /&gt;ELSE first_source END as Source_Flag&lt;BR /&gt;from oralib.sum_email_list_vw ;&lt;BR /&gt;quit;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2017 17:15:28 GMT</pubDate>
    <dc:creator>D7</dc:creator>
    <dc:date>2017-04-07T17:15:28Z</dc:date>
    <item>
      <title>SAS SQL - CASE STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348214#M80611</link>
      <description>&lt;P&gt;Hi, I'm using a case else statement to try to create a new variable (source_flag) to fill in for blank for the first_source variable, however it is not populating the new variable definition of 'unknown' when it runs. &amp;nbsp;Any help would be greately appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table d02_buyer_source_recency as&lt;BR /&gt;select DISTINCT email_id,&lt;BR /&gt;/* first source */&lt;BR /&gt;first_source,&lt;BR /&gt;first_available_source,&lt;BR /&gt;CASE when (first_source = ' ' OR first_source = '.') then 'UNKNOWN'&lt;BR /&gt;ELSE first_source END as Source_Flag&lt;BR /&gt;from oralib.sum_email_list_vw ;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 17:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348214#M80611</guid>
      <dc:creator>D7</dc:creator>
      <dc:date>2017-04-07T17:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL - CASE STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348220#M80613</link>
      <description>&lt;P&gt;It's not fully clear without seeing your data, but you could try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CASE first_source WHEN '' THEN 'UNKNOWN'&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHEN '.' THEN 'UNKNOWN'&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE first_source&lt;/P&gt;&lt;P&gt;END AS Source_Flag&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 17:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348220#M80613</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-07T17:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL - CASE STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348238#M80615</link>
      <description>&lt;P&gt;Hi, thank you for your recommendation, however when I ran the adjustment still gettting 'blank' variable instead of 'unknown' in the source_flag fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 17:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348238#M80615</guid>
      <dc:creator>D7</dc:creator>
      <dc:date>2017-04-07T17:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL - CASE STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348242#M80617</link>
      <description>&lt;P&gt;I assume first_source is character. Are there embedded blanks? Maybe put strip(first_source) for the CASE statement?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 18:02:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348242#M80617</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-07T18:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL - CASE STATEMENT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348370#M80651</link>
      <description>&lt;P&gt;Make sure your character variable is really empty. It might just look empty, but really include non-printing characters like tabs, line feeds, carriage returns, form feeds, non-breaking spaces, nulls. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also it might look like it has just a period in it, but it really has a period that follows one or move spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CASE when compress(first_source) in (' ','.')  then 'UNKNOWN'
     ELSE first_source 
END as Source_Flag&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Apr 2017 05:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-CASE-STATEMENT/m-p/348370#M80651</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-08T05:07:19Z</dc:date>
    </item>
  </channel>
</rss>

