<?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: how to get .xlsx worksheet names added as a variable using append in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323019#M21597</link>
    <description>&lt;P&gt;Can you use a libname method to import your data? If so then the INDSNAME would be an option to add the sheet name easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname inxls xlsx 'Path to xlsx file';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set sheet1 sheet2 sheet3 indsname=source;&lt;/P&gt;
&lt;P&gt;sheet=source;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname inxls;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2017 16:04:14 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-01-06T16:04:14Z</dc:date>
    <item>
      <title>how to get .xlsx worksheet names added as a variable using append</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323017#M21595</link>
      <description>&lt;P&gt;I have a single xlxs file with&amp;nbsp;multiple worksheets. &amp;nbsp;The same 3 variables are on each worksheet, but the worksheet name provides the group id the data belongs to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to import the worksheets; append into a single datafile; and analyze. &amp;nbsp;ODBC connect to open and PROC APPEND do this easily. &amp;nbsp;My problem is there is there doesn't appear to be the option to add worksheet name as an additional output var in&amp;nbsp;the appended data output table to provide a group id for analysis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I get from ODBC + PROC APPEND&lt;/P&gt;&lt;P&gt;var1 var2 var3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want&lt;/P&gt;&lt;P&gt;worksheet_name &amp;nbsp;var1 var2 var3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Know could just do create query for each worksheet and add the name variable there, then do append; but my actual file has 23 worksheets and trying to simplify. &amp;nbsp;Any ideas or direction to something I am missing are appreciated! &amp;nbsp;Thanks, Eric&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 15:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323017#M21595</guid>
      <dc:creator>hixsone</dc:creator>
      <dc:date>2017-01-06T15:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to get .xlsx worksheet names added as a variable using append</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323019#M21597</link>
      <description>&lt;P&gt;Can you use a libname method to import your data? If so then the INDSNAME would be an option to add the sheet name easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname inxls xlsx 'Path to xlsx file';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set sheet1 sheet2 sheet3 indsname=source;&lt;/P&gt;
&lt;P&gt;sheet=source;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname inxls;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 16:04:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323019#M21597</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-06T16:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to get .xlsx worksheet names added as a variable using append</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323023#M21598</link>
      <description>&lt;P&gt;Just use the XLSX libname engine and the INDSNAME= option on the SET statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mydata xlsx 'name of file.xlsx';
proc sql noprint ;
  select catx('.',libname,memname)
    into :dslist separated by ' '
    from dictionary.members 
    where libname='MYDATA'
  ;
quit;

data want ;
   length dsn group $50 ;
   set &amp;amp;dslist indsname=dsn ;
   group = scan(dsn,-1,'.') ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure why you would want to bother with ODBC. &amp;nbsp;Perhaps if could help if the sheets are not in a normal data format.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 16:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323023#M21598</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-01-06T16:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to get .xlsx worksheet names added as a variable using append</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323163#M21605</link>
      <description>&lt;P&gt;Thank you for the reply!&lt;/P&gt;&lt;P&gt;The libname statement works but am erroring because looking for Sheet1...3 in Work library for some reason. &amp;nbsp;Here is log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;25 libname inxls xlsx 'C:\Users\hixsone\Documents\Temp\mort3.xlsx';&lt;BR /&gt;NOTE: Libref INXLS was successfully assigned as follows:&lt;BR /&gt;Engine: XLSX&lt;BR /&gt;Physical Name: C:\Users\hixsone\Documents\Temp\mort3.xlsx&lt;BR /&gt;26 data want2;&lt;BR /&gt;27 set Sheet1 Sheet2 Sheet3 indsname=source;&lt;BR /&gt;ERROR: File WORK.SHEET1.DATA does not exist.&lt;BR /&gt;ERROR: File WORK.SHEET2.DATA does not exist.&lt;BR /&gt;ERROR: File WORK.SHEET3.DATA does not exist.&lt;BR /&gt;28 sheet=source;&lt;BR /&gt;29 run;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2017 17:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323163#M21605</guid>
      <dc:creator>hixsone</dc:creator>
      <dc:date>2017-01-07T17:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to get .xlsx worksheet names added as a variable using append</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323164#M21606</link>
      <description>&lt;P&gt;Thank you for the reply! &amp;nbsp;This worked with a couple modifications. &amp;nbsp;Had to remove and characters (e.g. '&amp;amp;', ',') and spaces from worksheet names. &amp;nbsp;Also had to change 'length dsn group $50' to '$250' because some of the worksheet names were long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding why ODBC: Originaly I just used toolbar controls and drag/drop table append (i.e. open ODBC source, machine source, select file, select worksheets). &amp;nbsp;Avoiding writing code...&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2017 17:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-xlsx-worksheet-names-added-as-a-variable-using-append/m-p/323164#M21606</guid>
      <dc:creator>hixsone</dc:creator>
      <dc:date>2017-01-07T17:37:25Z</dc:date>
    </item>
  </channel>
</rss>

