<?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: append a column to a dataset from another table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/append-a-column-to-a-dataset-from-another-table/m-p/790375#M253049</link>
    <description>&lt;P&gt;SQL is a &lt;A href="https://beginnersbook.com/2019/02/introduction-to-relational-algebra-calculus/" target="_self"&gt;relational algebra.&amp;nbsp;&lt;/A&gt; So you need some RELATION to have it operate.&lt;/P&gt;
&lt;P&gt;It has no way to refer to an observation by POSITION in the dataset, so there is no way in a pure SQL dialect you could combine data without some values to match on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But a SAS data step will process the data from a dataset sequentially. You can just set the two datasets together.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set d1;
  set sashelp.cars(keep=make);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS Using separate steps to "add" a variable to a dataset and populate the values makes no sense from a performance point of view.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 15 Jan 2022 22:52:15 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-01-15T22:52:15Z</dc:date>
    <item>
      <title>append a column to a dataset from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-a-column-to-a-dataset-from-another-table/m-p/790342#M253026</link>
      <description>&lt;P&gt;Practing SAS sql and curious on how to directly append another column from a seperate data set into a different data set without having a unique key to join on.&amp;nbsp; Say I table A with customers&amp;nbsp; and address in one table and Table B&amp;nbsp; has&amp;nbsp;&lt;/P&gt;&lt;P&gt;customers and account number . Customers is not unique (lots of Joe Smith's in the world) but I know they were added to the system&amp;nbsp; in exactly the same order&amp;nbsp; and records are in a one-to-one manner.&amp;nbsp; How do I aggregate the two into a master table?&amp;nbsp; Sure its simple so sorry for being a bother.&amp;nbsp; Thanks !!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what I tried&lt;/P&gt;&lt;P&gt;------------------------------------------&amp;nbsp;&lt;/P&gt;&lt;P&gt;data d1&lt;BR /&gt;set sashelp.cars;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;/*adding column */&lt;BR /&gt;alter table d1&lt;BR /&gt;add make char;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*trying to insert make values back into the table */&lt;BR /&gt;update d1 set make =&lt;BR /&gt;(select make from sashelp.cars);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jan 2022 18:52:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-a-column-to-a-dataset-from-another-table/m-p/790342#M253026</guid>
      <dc:creator>thryce85</dc:creator>
      <dc:date>2022-01-15T18:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: append a column to a dataset from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-a-column-to-a-dataset-from-another-table/m-p/790343#M253027</link>
      <description>I don't know if there's a SQL construct to do that, but there is in data step - MERGE without a BY statement. &lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;merge d1 cars(keep=make);&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Sat, 15 Jan 2022 18:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-a-column-to-a-dataset-from-another-table/m-p/790343#M253027</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-15T18:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: append a column to a dataset from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-a-column-to-a-dataset-from-another-table/m-p/790344#M253028</link>
      <description>awesome thanks for the info</description>
      <pubDate>Sat, 15 Jan 2022 19:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-a-column-to-a-dataset-from-another-table/m-p/790344#M253028</guid>
      <dc:creator>thryce85</dc:creator>
      <dc:date>2022-01-15T19:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: append a column to a dataset from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/append-a-column-to-a-dataset-from-another-table/m-p/790375#M253049</link>
      <description>&lt;P&gt;SQL is a &lt;A href="https://beginnersbook.com/2019/02/introduction-to-relational-algebra-calculus/" target="_self"&gt;relational algebra.&amp;nbsp;&lt;/A&gt; So you need some RELATION to have it operate.&lt;/P&gt;
&lt;P&gt;It has no way to refer to an observation by POSITION in the dataset, so there is no way in a pure SQL dialect you could combine data without some values to match on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But a SAS data step will process the data from a dataset sequentially. You can just set the two datasets together.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set d1;
  set sashelp.cars(keep=make);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS Using separate steps to "add" a variable to a dataset and populate the values makes no sense from a performance point of view.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jan 2022 22:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/append-a-column-to-a-dataset-from-another-table/m-p/790375#M253049</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-15T22:52:15Z</dc:date>
    </item>
  </channel>
</rss>

