@kparikh
I couldn't find where that's documented but it appears you can get what you want by also defining a FILENAME wit MOD pointing to the same location than your XML Libname.
libname test xmlv2 "c:\temp\demo.xml" ;
filename test "%sysfunc(pathname(test))" mod;
data test.class;
set sashelp.class(obs=1);
run;
data test.air;
set sashelp.air(obs=2);
run;
libname test;
filename test;
demo.xml
<?xml version="1.0" encoding="windows-1252" ?>
<TABLE>
<CLASS>
<Name>Alfred</Name>
<Sex>M</Sex>
<Age>14</Age>
<Height>69</Height>
<Weight>112.5</Weight>
</CLASS>
<AIR>
<DATE>1949-01-01</DATE>
<AIR>112</AIR>
</AIR>
<AIR>
<DATE>1949-02-01</DATE>
<AIR>118</AIR>
</AIR>
</TABLE>
You can also use Proc Datasets for this task so you don't need to loop over tables and rows in tables but simply pass in a list of tables to be copied. And it appears with Proc Datasets you append "out-of-the-box" and don't need the Filename statement.
I've done some testing and Appending even happens with multiple Proc Datasets and even with multiple sessions.
libname test xmlv2 "c:\temp\demo.xml" ;
/*filename test "%sysfunc(pathname(test))" mod;*/
proc datasets lib=sashelp nolist;
copy in=sashelp out=test;
select class airline;
run;
quit;
proc datasets lib=sashelp nolist;
copy in=sashelp out=test;
select air;
run;
quit;
libname test;
/*filename test;*/
I believe what that means: Understand your demo.xml when assigned via a Libname XML statement like any other library. You wouldn't expect there that you wipe out all the tables only because you replace one of the tables. It appears the Libname statement with a SAS datastep but without the Filename Mod statement behaves here actually a bit inconsistent.
And now given all of the above the way I'd implement: First have a data step so you wipe out and re-create your xml whenever you re-run the code, then use Proc Datasets for all tables to be appended.
libname test xmlv2 "c:\temp\demo.xml" ;
data test.class;
set sashelp.class;
run;
proc datasets lib=sashelp nolist;
copy in=sashelp out=test;
select air airline;
run;
quit;
libname test;
... View more