<?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: merge files while adding new column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merge-files-while-adding-new-column/m-p/404607#M98347</link>
    <description>&lt;P&gt;Probably all the incoming datasets have the same variables.&amp;nbsp; If so, I recommend adding the "open=defer" option to the SET statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set xxx.xx_:&amp;nbsp;&amp;nbsp; indsname=source &lt;EM&gt;&lt;STRONG&gt;open=defer&lt;/STRONG&gt;&lt;/EM&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of generating one buffer per incoming data set, this option re-uses the same buffer for each dataset.&amp;nbsp; Saves memory, with no real performance cost.&amp;nbsp;&amp;nbsp; And if the OP has not only ddJUN2017, but also the other months (ddJAN2017 ... ddDEC2017), a lot of memory gets saved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only problem would be the result would not be in chronological order (since all datasets named XXX.XX_ are read in alphabetical order).&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Oct 2017 21:33:46 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-10-16T21:33:46Z</dc:date>
    <item>
      <title>merge files while adding new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-files-while-adding-new-column/m-p/404509#M98326</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to merge files by using SET while adding new columns, like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let x=%str(XXX._XX_);&lt;BR /&gt;%let z=JUN2017;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro merge(y);&lt;BR /&gt;data b&amp;amp;y;&lt;BR /&gt;set&lt;BR /&gt;%do i=1 %to &amp;amp;y;&lt;BR /&gt;%let i2=%sysfunc(putn(&amp;amp;i,Z2));&lt;BR /&gt;&amp;amp;x.&amp;amp;i2.&amp;amp;z&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;U&gt;date = "&amp;amp;i2.&amp;amp;z";&lt;/U&gt;&lt;/FONT&gt;&lt;BR /&gt;%end;;&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%merge(10);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure where to put the red part, basically, I want to add a new Date column every time it go thru each SET (the original files dont have Date column in it, just marked in the file name)&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 15:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-files-while-adding-new-column/m-p/404509#M98326</guid>
      <dc:creator>okaka23</dc:creator>
      <dc:date>2017-10-16T15:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: merge files while adding new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-files-while-adding-new-column/m-p/404511#M98327</link>
      <description>&lt;P&gt;You can do that, but it may be easier to use the INDSNAME option instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This isn't a MERGE, it's an APPEND, since all data sets seem to have a common prefix&amp;nbsp;you may be able to avoid a macro entirely.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

set xxx._xx: indsname = source;

date = source;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Oct 2017 15:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-files-while-adding-new-column/m-p/404511#M98327</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-16T15:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: merge files while adding new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-files-while-adding-new-column/m-p/404607#M98347</link>
      <description>&lt;P&gt;Probably all the incoming datasets have the same variables.&amp;nbsp; If so, I recommend adding the "open=defer" option to the SET statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set xxx.xx_:&amp;nbsp;&amp;nbsp; indsname=source &lt;EM&gt;&lt;STRONG&gt;open=defer&lt;/STRONG&gt;&lt;/EM&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of generating one buffer per incoming data set, this option re-uses the same buffer for each dataset.&amp;nbsp; Saves memory, with no real performance cost.&amp;nbsp;&amp;nbsp; And if the OP has not only ddJUN2017, but also the other months (ddJAN2017 ... ddDEC2017), a lot of memory gets saved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only problem would be the result would not be in chronological order (since all datasets named XXX.XX_ are read in alphabetical order).&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 21:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-files-while-adding-new-column/m-p/404607#M98347</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-16T21:33:46Z</dc:date>
    </item>
  </channel>
</rss>

