<?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 How do I multiple a column in one table by a scalar value from another table? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-multiple-a-column-in-one-table-by-a-scalar-value-from/m-p/857476#M338819</link>
    <description>&lt;P&gt;Hello, I'm brand new to SAS and am struggling with syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two datasets: one 100x5 table called QUANTITIES, and one 2x12 table called COEFFICIENTS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to multiply all values in QUANTITIES column called "Weight" by the scalar value found in the COEFFICIENTS column called "Wheat".&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm able to manipulate QUANTITIES as long as I don't have to bring in any values from other datasets. For the life of me, I can't figure out how to pull in a number from COEFFICIENTS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.QUANTITIES; 
   input Name $ Weight Density Units@@; 
datalines; 
   Prod1  69.0 112.5 14  
   Prod2   62.8 102.5 14 
   Prod3    59.8  84.5 12  
   Prod4    59.0  99.5 12   
; 


data work.COEFFICIENTS; 
   input Copper Iron Wheat Barley Glass Water@@; 
datalines; 
   11 22 33 44 55 66 
; &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;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2023 02:11:45 GMT</pubDate>
    <dc:creator>bkr9000</dc:creator>
    <dc:date>2023-02-07T02:11:45Z</dc:date>
    <item>
      <title>How do I multiple a column in one table by a scalar value from another table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-multiple-a-column-in-one-table-by-a-scalar-value-from/m-p/857476#M338819</link>
      <description>&lt;P&gt;Hello, I'm brand new to SAS and am struggling with syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two datasets: one 100x5 table called QUANTITIES, and one 2x12 table called COEFFICIENTS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to multiply all values in QUANTITIES column called "Weight" by the scalar value found in the COEFFICIENTS column called "Wheat".&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm able to manipulate QUANTITIES as long as I don't have to bring in any values from other datasets. For the life of me, I can't figure out how to pull in a number from COEFFICIENTS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.QUANTITIES; 
   input Name $ Weight Density Units@@; 
datalines; 
   Prod1  69.0 112.5 14  
   Prod2   62.8 102.5 14 
   Prod3    59.8  84.5 12  
   Prod4    59.0  99.5 12   
; 


data work.COEFFICIENTS; 
   input Copper Iron Wheat Barley Glass Water@@; 
datalines; 
   11 22 33 44 55 66 
; &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;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 02:11:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-multiple-a-column-in-one-table-by-a-scalar-value-from/m-p/857476#M338819</guid>
      <dc:creator>bkr9000</dc:creator>
      <dc:date>2023-02-07T02:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiple a column in one table by a scalar value from another table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-multiple-a-column-in-one-table-by-a-scalar-value-from/m-p/857489#M338824</link>
      <description>&lt;P&gt;One way to work with ALL records of two data sets combined is in Proc SQL with a Cartesian join.&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table want as
   select a.*,b.wheat, a.weight*b.wheat as product
   from work.QUANTITIES as a, work.coefficients as b
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;The above code has all variables from the quantities set and the value of Wheat from the coefficients set plus a product of weight*wheat (you didn't provide a result variable name). the values of weight and wheat are shown to show which values are used but they would not necessarily have to be Selected to be in the set. The A.* is "bring in all the variables from set A" and the A and B are alias to represent the set names.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 05:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-multiple-a-column-in-one-table-by-a-scalar-value-from/m-p/857489#M338824</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-07T05:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I multiple a column in one table by a scalar value from another table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-multiple-a-column-in-one-table-by-a-scalar-value-from/m-p/857654#M338883</link>
      <description>Excellent, thank you for the solution and explanation! This is exactly what I was looking for.</description>
      <pubDate>Tue, 07 Feb 2023 20:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-multiple-a-column-in-one-table-by-a-scalar-value-from/m-p/857654#M338883</guid>
      <dc:creator>bkr9000</dc:creator>
      <dc:date>2023-02-07T20:11:18Z</dc:date>
    </item>
  </channel>
</rss>

