<?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: append all datasets from 1 library with new variable per set in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323571#M21619</link>
    <description>&lt;P&gt;Hi RW9,&lt;/P&gt;&lt;P&gt;I do not know what happend with my formatting yesterday. Here again the code. Hopefully this time it is readable. I will meanwhile read the proposed solutions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Import all sheets from excel file. For this example only 2 */&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; imp(sheet = );&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;PROC IMPORT OUT=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;SAS_TMP.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;sheet&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;datafile = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"\\DWCPMCA\Data\1_INPUTDOCS\IMPDOC\IL.xlsx"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;DBMS=xlsx REPLACE;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;sheet=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sheet."&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;GETNAMES=YES;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; imp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;imp&lt;/I&gt;&lt;/STRONG&gt;(sheet=V100_IL)&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;imp&lt;/I&gt;&lt;/STRONG&gt;(sheet=V350_IL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;U&gt;/* OPTION 1: append the imported sheets using set */ &amp;lt;&amp;lt; HOW can I make the set more automated?&amp;gt;&amp;gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SAS_TMP.want;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sas_tmp.V100_IL sas_tmp.V350_IL;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;/* OPTION 2: using proc append and reading all the imported sheets into my SAS_TMP lib */&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; count(*) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; : obs &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sashelp.vtable&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; libname = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SAS_TMP'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%LET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; OBS=&amp;amp;OBS;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; catx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'.'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SAS_TMP'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, memname) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;INTO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; : TAB1-:TAB&amp;amp;OBS &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sashelp.vtable&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; libname = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SAS_TMP'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;append&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%DO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;obs;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;proc append base=SAS_TMP.tot_comb data=&amp;amp;&amp;amp;tab&amp;amp;i force;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;append&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2017 11:06:10 GMT</pubDate>
    <dc:creator>RensMeerman</dc:creator>
    <dc:date>2017-01-10T11:06:10Z</dc:date>
    <item>
      <title>append all datasets from 1 library with new variable per set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323393#M21613</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to do something smart but I'm failing and do not know how to fix it. I have (several) xlsx files with multimple sheets. For this example I'm importing 1 xlsx file and only to sheets ( in reality it has 5).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alfter the import I want to append them so that I can transpose them later from 1 table. I first tried the set option but I do not know how to make it flexible, since I do not want to manually add the sheet names one more (OPTION 1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I've found the code for OPTION 2, but then I get a warning that not all my variables are added&amp;nbsp; due to : Variable was not found on BASE file. The variable will not be added to the BASE file. (see attachment)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;CODE class=" language-sas"&gt;/* Import all sheets from excel file. For this example only 2 */


%macro imp(sheet = );

PROC IMPORT OUT=SAS_TMP.&amp;amp;sheet

 datafile = "\\DWCPMCA\Data\1_INPUTDOCS\IMPDOC\IL.xlsx"

DBMS=xlsx REPLACE;

 sheet="&amp;amp;sheet.";

GETNAMES=YES;

run;

%mend imp;

%imp(sheet=V100_IL)

%imp(sheet=V350_IL)




/* OPTION 1: append using set */


data SAS_TMP.want;

set sas_tmp.V100_IL sas_tmp.V350_IL;

run; 




/* OPTION 2: using proc append */


proc sql;

select count(*) into : obs from sashelp.vtable

where libname = 'SAS_TMP';

%LET OBS=&amp;amp;OBS;

SELECT catx('.', 'SAS_TMP', memname) INTO : TAB1-:TAB&amp;amp;OBS FROM sashelp.vtable

where libname = 'SAS_TMP';

QUIT;

%MACRO append;

%DO i=1 %to &amp;amp;obs;

proc append base=SAS_TMP.tot_comb data=&amp;amp;&amp;amp;tab&amp;amp;i force;run;

%end;

%mend;

%append;

proc print data=SAS_TMP.tot_comb;

run; &lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jan 2017 16:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323393#M21613</guid>
      <dc:creator>RensMeerman</dc:creator>
      <dc:date>2017-01-09T16:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: append all datasets from 1 library with new variable per set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323401#M21614</link>
      <description>&lt;P&gt;Seriously, I mean this in the best possible way, how am I supposed to read that mess of text? &amp;nbsp;Follow some sort of good programming practice, lower case code, new line for each item, indent where necessary etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First question, how will you know that each sheet is the same strcuturally and after import? &amp;nbsp;I can guarantee you that importing data from Excel - which is a terrible data medium - will give you different results every time you do it. &amp;nbsp;Also using proc import - which is a guessing procedure - may guess your data differently each time. &amp;nbsp;Hence there is 99% chance that each sheet at every import will have a different strcuture. &amp;nbsp;This will cause you problems appending the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My suggestion, get your data out into a proper data transfer format - csv/delimted text, xml etc. &amp;nbsp;Then write a datastep import and specify the data import structure - that you know as its your data. &amp;nbsp;That way you can reduce the possiblilties that the data is different (either content or structural).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have sorted that part of the process out, then you can look at appending all the data, simply querying the sashelp.vtable view you can identify all the datasets, then loop over them and append them. &amp;nbsp;you could also at the import stage read all the files at once using wildards for instance.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 16:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323401#M21614</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-09T16:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: append all datasets from 1 library with new variable per set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323406#M21615</link>
      <description>&lt;P&gt;I don't see any ERROR message in your log you posted.&lt;/P&gt;
&lt;P&gt;What is the problem ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You used the &lt;STRONG&gt;FORCE&lt;/STRONG&gt; option in &lt;STRONG&gt;PROC APPEND&lt;/STRONG&gt; so all new variables should apear in the agregated output dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only problem can be that &lt;STRONG&gt;text&lt;/STRONG&gt; variables could be &lt;STRONG&gt;trancated&lt;/STRONG&gt; to their first length occirence.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 16:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323406#M21615</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-09T16:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: append all datasets from 1 library with new variable per set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323410#M21616</link>
      <description>&lt;P&gt;The FORCE option just let's you append from dataset that have extra variables. It does NOT add the variables, that would totally go against the point of PROC APPEND it that it would require re-writing the BASE dataset. &amp;nbsp;If you want to add new variables just use a data step instead of PROC APPEND.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
   set BASE DATA ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jan 2017 16:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323410#M21616</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-01-09T16:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: append all datasets from 1 library with new variable per set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323448#M21617</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The FORCE option just let's you append from dataset that have extra variables. It does NOT add the variables, that would totally go against the point of PROC APPEND it that it would require re-writing the BASE dataset. &amp;nbsp;If you want to add new variables just use a data step instead of PROC APPEND.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
   set BASE DATA ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And if you have imported all of the sets then&lt;/P&gt;
&lt;PRE&gt;data want ;
   set BASE DATA1 data2 data3 ... datan ;
run;&lt;/PRE&gt;
&lt;P&gt;And when you get the almost inevitable errors or warnings about mismatched data types or lengths of varaibles refer to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;'s post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 19:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323448#M21617</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-09T19:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: append all datasets from 1 library with new variable per set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323571#M21619</link>
      <description>&lt;P&gt;Hi RW9,&lt;/P&gt;&lt;P&gt;I do not know what happend with my formatting yesterday. Here again the code. Hopefully this time it is readable. I will meanwhile read the proposed solutions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Import all sheets from excel file. For this example only 2 */&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; imp(sheet = );&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;PROC IMPORT OUT=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;SAS_TMP.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;sheet&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;datafile = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"\\DWCPMCA\Data\1_INPUTDOCS\IMPDOC\IL.xlsx"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;DBMS=xlsx REPLACE;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;sheet=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sheet."&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;GETNAMES=YES;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; imp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;imp&lt;/I&gt;&lt;/STRONG&gt;(sheet=V100_IL)&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;imp&lt;/I&gt;&lt;/STRONG&gt;(sheet=V350_IL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;U&gt;/* OPTION 1: append the imported sheets using set */ &amp;lt;&amp;lt; HOW can I make the set more automated?&amp;gt;&amp;gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SAS_TMP.want;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sas_tmp.V100_IL sas_tmp.V350_IL;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;/* OPTION 2: using proc append and reading all the imported sheets into my SAS_TMP lib */&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; count(*) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; : obs &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sashelp.vtable&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; libname = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SAS_TMP'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%LET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; OBS=&amp;amp;OBS;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; catx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'.'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SAS_TMP'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, memname) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;INTO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; : TAB1-:TAB&amp;amp;OBS &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sashelp.vtable&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; libname = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SAS_TMP'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;append&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%DO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;obs;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;proc append base=SAS_TMP.tot_comb data=&amp;amp;&amp;amp;tab&amp;amp;i force;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;append&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 11:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323571#M21619</guid>
      <dc:creator>RensMeerman</dc:creator>
      <dc:date>2017-01-10T11:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: append all datasets from 1 library with new variable per set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323577#M21620</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So:&lt;/P&gt;
&lt;P&gt;Opt1:&lt;/P&gt;
&lt;P&gt;/* Assumes all dataset in library sas_tmp with prefix V are to be set together - note the ":"&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SAS_TMP.want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&amp;nbsp; set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sas_tmp.V:; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;For your code:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;%macro imp(sheet = );
  proc import out=sas_tmp.&amp;amp;sheet. datafile="\\dwcpmca\data\1_inputdocs\impdoc\il.xlsx" dbms=xlsx replace;
    sheet="&amp;amp;sheet.";
    getnames=yes;
  run;
%mend imp;
%imp(sheet=v100_il);
%imp(sheet=v350_il);&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;You could also replace this with &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="3"&gt;libname tmp excel "\\dwcpmca\data\1_inputdocs\impdoc\il.xlsx";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="3"&gt;ASsuming you have SAS 9.4. &amp;nbsp;Then you could access the sheets directly from tmp library.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;For this code:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  select  count(*) 
  into    :OBS from SASHELP.VTABLE
  where   LIBNAME='SAS_TMP';
  select  catx('.','SAS_TMP',MEMNAME)
  into    :TAB1-:TAB&amp;amp;OBS.
  from    SASHELP.VTABLE
  where   LIBNAME='SAS_TMP';
quit;
 
%macro append;
  %do i=1 %to &amp;amp;obs.;
    proc append base=sas_tmp.tot_comb data=&amp;amp;&amp;amp;tab&amp;amp;i force;
    run;
  %end;
%mend;
%append;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;You can simplify this by:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="SAS_TMP"));
  call execute(cats('proc append base=sas_tmp.tot_comb data=',memname,' force;run;'));
run;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;However, this still doesn't cover the inherent problems with a) Excel, b) Import methods. &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 11:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323577#M21620</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-10T11:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: append all datasets from 1 library with new variable per set</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323759#M21632</link>
      <description>Thanks. This helps me further. The XLS en Import problems will be tackled in a next phase.</description>
      <pubDate>Tue, 10 Jan 2017 20:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/append-all-datasets-from-1-library-with-new-variable-per-set/m-p/323759#M21632</guid>
      <dc:creator>RensMeerman</dc:creator>
      <dc:date>2017-01-10T20:26:08Z</dc:date>
    </item>
  </channel>
</rss>

