<?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 Calculate a value by making mathematical calculations on different columns in different tables using SQL? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-a-value-by-making-mathematical-calculations-on/m-p/196672#M49174</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I have multiple tables with only one record in each one of them. I have another table which combines all the tables in one table.&lt;/P&gt;&lt;P&gt;What i'm trying to do is to calculate a value from multiple tables (subtract and add) to then create a new column with the result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your help is appreciated .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 31 May 2015 12:14:31 GMT</pubDate>
    <dc:creator>MustafaAbdelhaq</dc:creator>
    <dc:date>2015-05-31T12:14:31Z</dc:date>
    <item>
      <title>Calculate a value by making mathematical calculations on different columns in different tables using SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-a-value-by-making-mathematical-calculations-on/m-p/196672#M49174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I have multiple tables with only one record in each one of them. I have another table which combines all the tables in one table.&lt;/P&gt;&lt;P&gt;What i'm trying to do is to calculate a value from multiple tables (subtract and add) to then create a new column with the result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your help is appreciated .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 31 May 2015 12:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-a-value-by-making-mathematical-calculations-on/m-p/196672#M49174</guid>
      <dc:creator>MustafaAbdelhaq</dc:creator>
      <dc:date>2015-05-31T12:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a value by making mathematical calculations on different columns in different tables using SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-a-value-by-making-mathematical-calculations-on/m-p/196673#M49175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use SASHELP.VTABLE and call execute to generate the SQL queries:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Create three example tables */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data table_A table_B table_C;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = 1,2,3; output; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data _null_;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;length oldTable newTable $41;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;call execute("proc sql;");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do until (done);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Get the table names */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.vtable(&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where=(libname="WORK" and memname like "TABLE_%")) end=done;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldTable = cats(libname, ".", memname);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Create the new table name from the old one */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newTable = cats(oldTable, "_new");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Create the query with the definition of the new variable */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(catx(" ", "create table", newTable, "as select *, x+1 as y from", oldTable, ";"));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;call execute("quit;");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;stop;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Execution of the SQL procedure will occur here */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jun 2015 02:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-a-value-by-making-mathematical-calculations-on/m-p/196673#M49175</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-06-01T02:13:20Z</dc:date>
    </item>
  </channel>
</rss>

