<?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: How to add a variable to a table in proc SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749410#M235490</link>
    <description>&lt;P&gt;Please read the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0a85s0ijz65irn1h3jtariooea5.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt; and try running the code. If it is still not clear then ask further questions.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jun 2021 05:08:15 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2021-06-22T05:08:15Z</dc:date>
    <item>
      <title>How to add a variable to a table in proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749406#M235486</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;I code as follows:&lt;/P&gt;
&lt;P&gt;if member_ID in ('k') then tempbucket = 'Health plan v';&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;/P&gt;
&lt;P&gt;create table mydata as&lt;/P&gt;
&lt;P&gt;select distinct a.member_ID&lt;/P&gt;
&lt;P&gt;from tablec a;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I want to add this tempbucket to my table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please let know how?&lt;/P&gt;
&lt;P&gt;I have searched a lot!&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Blue Blue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 03:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749406#M235486</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-06-22T03:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a variable to a table in proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749407#M235487</link>
      <description>&lt;P&gt;In SQL the CASE statement can do similar logic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table mydata as
select distinct a.member_ID
      ,case
        when a.member_ID in ('k') then 'Health plan v'
       else ''
      end as tempbucket
from tablec a;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jun 2021 04:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749407#M235487</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-06-22T04:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a variable to a table in proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749408#M235488</link>
      <description>&lt;P&gt;Thanks for the response.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me try it tomorrow and I will get back to you:&lt;/P&gt;
&lt;P&gt;Does this add a new variable? Or test different cases? Anyway, case statement can solve my situation.&lt;/P&gt;
&lt;P&gt;If it is not "k only" it is "k" or "n", then what happens? I mean to use "or" with "in".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we bring our new variable after the word "case"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc sql;
create table mydata as
select distinct a.member_ID
      ,case
        when a.member_ID in ('k') then 'Health plan v'
       else ''
      end as tempbucket
from tablec a;
quit;&lt;/PRE&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Blue, Blue&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 04:53:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749408#M235488</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-06-22T04:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a variable to a table in proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749410#M235490</link>
      <description>&lt;P&gt;Please read the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0a85s0ijz65irn1h3jtariooea5.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt; and try running the code. If it is still not clear then ask further questions.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 05:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749410#M235490</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-06-22T05:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a variable to a table in proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749764#M235686</link>
      <description>This response saved me. Thanks &lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt; &lt;BR /&gt;Blue blue</description>
      <pubDate>Wed, 23 Jun 2021 01:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-variable-to-a-table-in-proc-SQL/m-p/749764#M235686</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-06-23T01:33:10Z</dc:date>
    </item>
  </channel>
</rss>

