<?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: adding a column for multiple tables in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/244240#M6414</link>
    <description>&lt;P&gt;The solution above is what i really wanted&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2016 15:32:42 GMT</pubDate>
    <dc:creator>lissacoffey</dc:creator>
    <dc:date>2016-01-18T15:32:42Z</dc:date>
    <item>
      <title>adding a column for multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243404#M6373</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose that I have 3 tables: A,B,C.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I would like to do is for each table to add a new column called "table" and the value in each row of this new column for each table is the name of the table itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So table A will have a new column "table" with values a, a, a, a, ....&lt;/P&gt;
&lt;P&gt;table B will have a new column named "table" with values b,b,b,...&lt;/P&gt;
&lt;P&gt;And so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 04:22:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243404#M6373</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-01-14T04:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: adding a column for multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243406#M6374</link>
      <description>&lt;P&gt;Why would you want to do this?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 04:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243406#M6374</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-14T04:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: adding a column for multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243407#M6375</link>
      <description>&lt;P&gt;Take advantage of the INDSNAME option to automatically grab the table name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm really curious for the use case of adding this variable, besides when you are setting multiple tables together and even then you can use the INDSNAME option directly.&amp;nbsp;&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;
&lt;PRE&gt;%macro add_name(dsn);

data &amp;amp;dsn;
set &amp;amp;dsn indsname=source;
Table = scan(source, 2);
run;

%mend;

%add_name(tableA);
%add_name(TableB)&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 15:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243407#M6375</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-18T15:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: adding a column for multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243408#M6376</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have many tables of stocks. Each table is named after the stock and has two columns: "date" and "daily price".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to perform my analysis I need to merge all the tables together into one table, but since there is no indicator which date and price is for which stock, the analysis won't be possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 04:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243408#M6376</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-01-14T04:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: adding a column for multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243409#M6377</link>
      <description>I did put the answer above, under the spoiler tag on how you could do it via a macro. The solution below is what you really want though, which is what I suspected. &lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set stock1 stock2 stock3 stock4 indsname=source;&lt;BR /&gt;table=scan(source, 2);&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Jan 2016 04:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243409#M6377</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-14T04:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: adding a column for multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243411#M6378</link>
      <description>&lt;P&gt;Thank you Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I got the answer that I needed!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Indsname happens to be a very useful function, I didn't even know it existed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again!!!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 05:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/243411#M6378</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-01-14T05:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: adding a column for multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/244240#M6414</link>
      <description>&lt;P&gt;The solution above is what i really wanted&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 15:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/adding-a-column-for-multiple-tables/m-p/244240#M6414</guid>
      <dc:creator>lissacoffey</dc:creator>
      <dc:date>2016-01-18T15:32:42Z</dc:date>
    </item>
  </channel>
</rss>

