<?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: proc append - keep identifier in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176660#M45280</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could create views which contains the years, have proc append read from those instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Feb 2014 10:50:25 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2014-02-17T10:50:25Z</dc:date>
    <item>
      <title>proc append - keep identifier</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176659#M45279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a library with data from four years (2010-2014) each dataset includes two variables: id and source&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;library:&lt;/P&gt;&lt;P&gt;data_2010&lt;/P&gt;&lt;P&gt;data_2011&lt;/P&gt;&lt;P&gt;data_2012&lt;/P&gt;&lt;P&gt;data_2013&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I now want to append these years and in the append step (or what step the best for doing this...) create a variable that tells you which year the data comes from. Like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; source&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year (new)&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2011&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2011&lt;/P&gt;&lt;P&gt;and so on...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd rather not create the variable in each dataset because they are huge&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to create this variable in the append step?&lt;/P&gt;&lt;P&gt;/Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 09:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176659#M45279</guid>
      <dc:creator>bollibompa</dc:creator>
      <dc:date>2014-02-17T09:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: proc append - keep identifier</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176660#M45280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could create views which contains the years, have proc append read from those instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 10:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176660#M45280</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-02-17T10:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc append - keep identifier</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176661#M45281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi bollibompa&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See code sample below, it uses some techniques available since SAS9.2 where you can specify data sets lists and the INDSNAME= option on the SET statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruno&lt;/P&gt;&lt;DIV style="font-family: Consolas; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; data_2010 data_2011&amp;nbsp; data_2012 data_2013;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; id = &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;5&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; source = char(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"ABCDEFG"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, id);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;output&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;end&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; data_want;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; data_2010 - data_2013 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;indsname&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=_dsname;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; year $ &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;4&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; year = scan(_dsname, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"_"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 13:05:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176661#M45281</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2014-02-17T13:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc append - keep identifier</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176662#M45282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;INDSNAME option on the SET statement is what you want.&lt;/P&gt;&lt;P&gt;But you might also want to look into using a BY statement with your SET so that the final dataset will still be sorted by ID.&amp;nbsp; And if you order the datasets in the SET statement properly then the final dataset will also be sorted by YEAR within ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length indsname $41 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set data_2010-data_2013 indsname=indsname ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id source ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; year = input(scan(idsname,-1,'_'),4.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 14:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176662#M45282</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-17T14:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc append - keep identifier</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176663#M45283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about this one&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;insert into all &lt;/P&gt;&lt;P&gt;select id,source, 2010 as source_file&lt;/P&gt;&lt;P&gt;from&amp;nbsp; data_2010&lt;/P&gt;&lt;P&gt;UNION&lt;/P&gt;&lt;P&gt;select id,source, 2011 as source_file&lt;/P&gt;&lt;P&gt;from&amp;nbsp; data_2011&lt;/P&gt;&lt;P&gt;UNION&lt;/P&gt;&lt;P&gt;select id,source, 2012 as source_file&lt;/P&gt;&lt;P&gt;from&amp;nbsp; data_2012&lt;/P&gt;&lt;P&gt;UNION&lt;/P&gt;&lt;P&gt;select id,source, 2013 as source_file&lt;/P&gt;&lt;P&gt;from&amp;nbsp; data_2013;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 16:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176663#M45283</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-02-17T16:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc append - keep identifier</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176664#M45284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for quick&amp;nbsp; replies!&lt;/P&gt;&lt;P&gt;INDSNAME was exactly what I was looking for, works perfect!&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Feb 2014 10:14:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/176664#M45284</guid>
      <dc:creator>bollibompa</dc:creator>
      <dc:date>2014-02-19T10:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc append - keep identifier</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/535634#M73928</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am reading huge xml files using xmlv2 libname and xmlmapper file.&lt;/P&gt;&lt;P&gt;After reading the each file, I need to add a source filename to the output dataset.&lt;/P&gt;&lt;P&gt;I can not use INDSNAME option because I must use PROC APPEND.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because my source file has missing columns or additional new columns every time.&lt;/P&gt;&lt;P&gt;This can be done only using PROC&amp;nbsp;APPEND with FORCE option.&lt;/P&gt;&lt;P&gt;Hence kindly guide me how can I add a new column in PROC APPEND?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 16:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-append-keep-identifier/m-p/535634#M73928</guid>
      <dc:creator>ArunSingapore</dc:creator>
      <dc:date>2019-02-14T16:25:53Z</dc:date>
    </item>
  </channel>
</rss>

