<?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 Adding New Variables in SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-New-Variables-in-SQL/m-p/550945#M153017</link>
    <description>&lt;P&gt;Suppose an easy data set as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _;
input i @@;
cards;
1 2 3 4 5 6 7 8 9 10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Using SET, one can create a new indicator variable as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _;
set _;
o=mod(i,2);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This can be similarly done through SQL as follows, but it spits out a warning message—WARNING: This CREATE TABLE statement recursively references the target table. A consequence of this is a possible data integrity problem.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table _ as
select *,mod(i,2)=0 as e
from _;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there any correct alternative?&lt;/P&gt;</description>
    <pubDate>Mon, 15 Apr 2019 01:54:11 GMT</pubDate>
    <dc:creator>Junyong</dc:creator>
    <dc:date>2019-04-15T01:54:11Z</dc:date>
    <item>
      <title>Adding New Variables in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-New-Variables-in-SQL/m-p/550945#M153017</link>
      <description>&lt;P&gt;Suppose an easy data set as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _;
input i @@;
cards;
1 2 3 4 5 6 7 8 9 10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Using SET, one can create a new indicator variable as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _;
set _;
o=mod(i,2);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This can be similarly done through SQL as follows, but it spits out a warning message—WARNING: This CREATE TABLE statement recursively references the target table. A consequence of this is a possible data integrity problem.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table _ as
select *,mod(i,2)=0 as e
from _;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there any correct alternative?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 01:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-New-Variables-in-SQL/m-p/550945#M153017</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-04-15T01:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Adding New Variables in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-New-Variables-in-SQL/m-p/550950#M153019</link>
      <description>&lt;P&gt;To avoid problems, this operation must be done in two steps in SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
alter table _ add o real;
update _ set o = mod(i,2);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Apr 2019 02:34:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-New-Variables-in-SQL/m-p/550950#M153019</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-04-15T02:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Adding New Variables in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-New-Variables-in-SQL/m-p/550961#M153026</link>
      <description>&lt;P&gt;Or to avoid processing the table twice:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table _TMP_TABLE_ as
  select *, mod(I,2)=0 as E
  from _;
quit;
proc datasets noprint;
  age _TMP_TABLE_ _;
quit;&lt;/CODE&gt;&lt;/PRE&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 03:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-New-Variables-in-SQL/m-p/550961#M153026</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-04-15T03:26:31Z</dc:date>
    </item>
  </channel>
</rss>

