<?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 to add a new column in existing dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-new-column-in-existing-dataset/m-p/300397#M63441</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add new columns to an existing dataset. The new column should contain the data from another dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sumOut;&lt;BR /&gt;set work.dresssales1;&lt;BR /&gt;sumvar=sum(_29_8_2013,_31_8_2013);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add the value that is stored in sumvar to a new dataset Retail. How do I do this ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Aditya&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Sep 2016 14:52:25 GMT</pubDate>
    <dc:creator>AdityaKir</dc:creator>
    <dc:date>2016-09-23T14:52:25Z</dc:date>
    <item>
      <title>How to add a new column in existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-new-column-in-existing-dataset/m-p/300397#M63441</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add new columns to an existing dataset. The new column should contain the data from another dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sumOut;&lt;BR /&gt;set work.dresssales1;&lt;BR /&gt;sumvar=sum(_29_8_2013,_31_8_2013);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add the value that is stored in sumvar to a new dataset Retail. How do I do this ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Aditya&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 14:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-new-column-in-existing-dataset/m-p/300397#M63441</guid>
      <dc:creator>AdityaKir</dc:creator>
      <dc:date>2016-09-23T14:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a new column in existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-new-column-in-existing-dataset/m-p/300404#M63445</link>
      <description>&lt;P&gt;Do you have variables in both data sets to identify which records are supposed to align such as a product identifier, store identifier, dates or possibly multiple variables? If you have those key variables are combinations of them duplicated within one or both of the data sets?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be better to provide examples of BOTH data sets. This link &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; has instructions on how to make data step code to replicate the data that you can post here or attach as a TEXT file.&lt;/P&gt;
&lt;P&gt;It is also a very good idea to provide an example of what your are looking for as a result in case your narrative description is incomplete.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 15:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-new-column-in-existing-dataset/m-p/300404#M63445</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-23T15:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a new column in existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-new-column-in-existing-dataset/m-p/391936#M94223</link>
      <description>&lt;P&gt;Without the information &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; asked for it is difficult to answer your question &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/99735"&gt;@AdityaKir&lt;/a&gt;.&amp;nbsp;&amp;nbsp;The code you provided already creates and adds a new column.&amp;nbsp;&amp;nbsp;However, it appears that you want to take the new variable sumvar, which is in the data set SumOut, and add it to a data set called Retail.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If SumOut contains only one record this code will add the sumvar value to every observation in Retail:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Retail
set Retail;
if _n_=1 then set SumOut(keep=sumvar);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If SumOut contains multiple records and an id variable this code will merge the sumvar value to the matching id value in Retail:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Retail;
merge Retail SumOut(keep=id sumvar);
by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 16:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-new-column-in-existing-dataset/m-p/391936#M94223</guid>
      <dc:creator>JaneEslinger</dc:creator>
      <dc:date>2017-08-30T16:56:53Z</dc:date>
    </item>
  </channel>
</rss>

