<?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: Creating a new variable for a SQL table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-for-a-SQL-table/m-p/639911#M190438</link>
    <description>&lt;P&gt;In general you don't add variables to an existing dataset.&lt;/P&gt;
&lt;P&gt;Just make a new dataset. Simple in regular SAS code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new_table;
  set combined;
  new_var=one-two;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if you want to stick with SQL syntax.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table new_table as
  select *,one-two as new_var
  from combined
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just make it when you make the dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table work.combined as
select
 a.Number
,a.County
,a.Counts
,a.Sickness
,a.One
,a.OverallSickness
,b.Number
,b.Two
,a.One - b.Two as new_var
from today a
   , yesterday b
where a.Number = b.Number
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Apr 2020 22:06:27 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-04-14T22:06:27Z</dc:date>
    <item>
      <title>Creating a new variable for a SQL table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-for-a-SQL-table/m-p/639904#M190433</link>
      <description>&lt;P&gt;Hey everyone! I succesfully created a SAS table with the code below but what I need/want to do now is add another column/variable that is equal to variables One - Two. Help please!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table work.combined as&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;select&lt;BR /&gt;a. Number,&lt;BR /&gt;a. County,&lt;BR /&gt;a. Counts,&lt;BR /&gt;a. Sickness,&lt;BR /&gt;a. One,&lt;BR /&gt;a. OverallSickness,&lt;BR /&gt;b. Number,&lt;BR /&gt;b. Two&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;from&lt;BR /&gt;today a,&lt;BR /&gt;yesterday b&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;where&lt;BR /&gt;a.Number = b.Number;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 21:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-for-a-SQL-table/m-p/639904#M190433</guid>
      <dc:creator>stephanicurry</dc:creator>
      <dc:date>2020-04-14T21:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable for a SQL table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-for-a-SQL-table/m-p/639911#M190438</link>
      <description>&lt;P&gt;In general you don't add variables to an existing dataset.&lt;/P&gt;
&lt;P&gt;Just make a new dataset. Simple in regular SAS code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new_table;
  set combined;
  new_var=one-two;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if you want to stick with SQL syntax.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table new_table as
  select *,one-two as new_var
  from combined
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just make it when you make the dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table work.combined as
select
 a.Number
,a.County
,a.Counts
,a.Sickness
,a.One
,a.OverallSickness
,b.Number
,b.Two
,a.One - b.Two as new_var
from today a
   , yesterday b
where a.Number = b.Number
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Apr 2020 22:06:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-for-a-SQL-table/m-p/639911#M190438</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-14T22:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable for a SQL table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-for-a-SQL-table/m-p/640122#M190582</link>
      <description>Thanks so much! This was exactly what I needed &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 15 Apr 2020 14:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-for-a-SQL-table/m-p/640122#M190582</guid>
      <dc:creator>stephanicurry</dc:creator>
      <dc:date>2020-04-15T14:56:43Z</dc:date>
    </item>
  </channel>
</rss>

