<?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: Select clause - calculating new column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-clause-calculating-new-column/m-p/306758#M65625</link>
    <description>&lt;P&gt;Hi Leon,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;use the keyword "calculated".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
   CREATE TABLE KLD_t AS
      SELECT CUSIP,
             YEAR,
             COMPANYNAME,
             COMPANYID,
             TICKER,
             COM_STR_NUM,
             COM_CON_NUM,
             DIV_STR_NUM,
             DIV_CON_NUM,
             EMP_STR_NUM,
             EMP_CON_NUM,
             ENV_STR_NUM,
             ENV_CON_NUM,
             PRO_STR_NUM,
             PRO_CON_NUM,
             COM_STR_NUM + DIV_STR_NUM + EMP_STR_NUM + ENV_STR_NUM + PRO_STR_NUM AS TOT_STR_NUM,
             COM_CON_NUM + DIV_CON_NUM + EMP_CON_NUM + ENV_CON_NUM + PRO_CON_NUM AS TOT_CON_NUM,
             calculated TOT_STR_NUM - calculated TOT_CON_NUM AS KLD_SCORE
      FROM kld.kld
   ;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Oct 2016 12:19:03 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2016-10-24T12:19:03Z</dc:date>
    <item>
      <title>Select clause - calculating new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-clause-calculating-new-column/m-p/306757#M65624</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one simple question about select clause. I wanted to calculate a new column based on columns that was created within the same select clause. Then I have encountered the error message saying "The following columns were not found in the contributing tables: TOT_CON_NUM,&amp;nbsp;TOT_STR_NUM."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the log.&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;93 proc sql;&lt;BR /&gt;94 create table KLD_t as&lt;BR /&gt;95 select&lt;BR /&gt;96 CUSIP,&lt;BR /&gt;97 YEAR,&lt;BR /&gt;98 COMPANYNAME,&lt;BR /&gt;99 COMPANYID,&lt;BR /&gt;100 TICKER,&lt;BR /&gt;101 COM_STR_NUM,&lt;BR /&gt;102 COM_CON_NUM,&lt;BR /&gt;103 DIV_STR_NUM,&lt;BR /&gt;104 DIV_CON_NUM,&lt;BR /&gt;105 EMP_STR_NUM,&lt;BR /&gt;106 EMP_CON_NUM,&lt;BR /&gt;107 ENV_STR_NUM,&lt;BR /&gt;108 ENV_CON_NUM,&lt;BR /&gt;109 PRO_STR_NUM,&lt;BR /&gt;110 PRO_CON_NUM,&lt;BR /&gt;111 COM_STR_NUM + DIV_STR_NUM + EMP_STR_NUM + ENV_STR_NUM + PRO_STR_NUM AS TOT_STR_NUM,&lt;BR /&gt;112 COM_CON_NUM + DIV_CON_NUM + EMP_CON_NUM + ENV_CON_NUM + PRO_CON_NUM AS TOT_CON_NUM,&lt;BR /&gt;113 TOT_STR_NUM - TOT_CON_NUM as KLD_SCORE&lt;BR /&gt;114 from kld.kld&lt;BR /&gt;115 quit;&lt;BR /&gt;ERROR: The following columns were not found in the contributing tables: TOT_CON_NUM,&lt;BR /&gt;TOT_STR_NUM.&lt;/P&gt;&lt;P&gt;---------------------------------------&lt;/P&gt;&lt;P&gt;I understand that I can still calculate&amp;nbsp;KLD_SCORE after making a table with&amp;nbsp;&lt;SPAN&gt;TOT_STR_NUM and&amp;nbsp;TOT_CON_NUM then calculating KLD_SCORE again, but I am sure there's a way to do it just at once.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your help all the time!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 12:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-clause-calculating-new-column/m-p/306757#M65624</guid>
      <dc:creator>Leon_Seungmin</dc:creator>
      <dc:date>2016-10-24T12:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select clause - calculating new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-clause-calculating-new-column/m-p/306758#M65625</link>
      <description>&lt;P&gt;Hi Leon,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;use the keyword "calculated".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
   CREATE TABLE KLD_t AS
      SELECT CUSIP,
             YEAR,
             COMPANYNAME,
             COMPANYID,
             TICKER,
             COM_STR_NUM,
             COM_CON_NUM,
             DIV_STR_NUM,
             DIV_CON_NUM,
             EMP_STR_NUM,
             EMP_CON_NUM,
             ENV_STR_NUM,
             ENV_CON_NUM,
             PRO_STR_NUM,
             PRO_CON_NUM,
             COM_STR_NUM + DIV_STR_NUM + EMP_STR_NUM + ENV_STR_NUM + PRO_STR_NUM AS TOT_STR_NUM,
             COM_CON_NUM + DIV_CON_NUM + EMP_CON_NUM + ENV_CON_NUM + PRO_CON_NUM AS TOT_CON_NUM,
             calculated TOT_STR_NUM - calculated TOT_CON_NUM AS KLD_SCORE
      FROM kld.kld
   ;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 12:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-clause-calculating-new-column/m-p/306758#M65625</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2016-10-24T12:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select clause - calculating new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-clause-calculating-new-column/m-p/306760#M65626</link>
      <description>Thank you very much!</description>
      <pubDate>Mon, 24 Oct 2016 12:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-clause-calculating-new-column/m-p/306760#M65626</guid>
      <dc:creator>Leon_Seungmin</dc:creator>
      <dc:date>2016-10-24T12:21:42Z</dc:date>
    </item>
  </channel>
</rss>

