<?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: Keep excel sheet name as a variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176263#M45205</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You already have the value in a macro variable just create a new variable to hold the value.&lt;/P&gt;&lt;P&gt;Note that you are working too hard to pull the information into macro variables, you can create them and count them in one step.&lt;/P&gt;&lt;P&gt;Why does the DO loop start at 4 ???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; excelbook(path);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;libname d &amp;amp;path ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;proc sql noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; select memname&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , compress(memname,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"'$"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :s1-:s9999&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , :v1-:v9999&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sashelp.vtable&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'D'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; tot=&amp;amp;sqlobs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;libname d clear;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%to&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;tot;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; SHEET=&amp;amp;&amp;amp;s&amp;amp;i CODE=&amp;amp;&amp;amp;v&amp;amp;i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; proc import datafile=&amp;amp;path out=&amp;amp;&amp;amp;v&amp;amp;i&amp;nbsp; replace;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; range=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"&amp;amp;&amp;amp;s&amp;amp;i"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; getnames=no;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; data &amp;amp;&amp;amp;v&amp;amp;i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length sheet code $&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;32&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sheet=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"&amp;amp;&amp;amp;s&amp;amp;i"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; code=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"&amp;amp;&amp;amp;v&amp;amp;i"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;&amp;amp;v&amp;amp;i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; proc append base=all data=&amp;amp;&amp;amp;v&amp;amp;i force;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; excelbook;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;excelbook&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'f:\phdsas\book1.xls'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Apr 2014 23:13:22 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2014-04-10T23:13:22Z</dc:date>
    <item>
      <title>Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176254#M45196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Hello everyone,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I have a question regarding how to keep the excel sheet name as a variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Here is the code I used to import multiple excel sheets in SAS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro excelbook; &lt;/P&gt;&lt;P&gt;libname D 'F:\phdsas\Book1.xls';&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select count (distinct (memname)) INTO :TOT&lt;/P&gt;&lt;P&gt;from sashelp.vtable&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;where libname='D' ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT (memname) into :s1-:s%trim(%left(&amp;amp;tot))&lt;/P&gt;&lt;P&gt;from sashelp.vtable&lt;/P&gt;&lt;P&gt;where libname='D';&lt;/P&gt;&lt;P&gt;select distinct(compress(MEMNAME,"'$")) into: v1 - :v%trim(%left(&amp;amp;tot))&lt;/P&gt;&lt;P&gt;from sashelp.vtable&lt;/P&gt;&lt;P&gt;where libname='D';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;libname D clear;&lt;/P&gt;&lt;P&gt; %DO I=4 %TO &amp;amp;tot;&lt;/P&gt;&lt;P&gt; %put &amp;amp;&amp;amp;v&amp;amp;i;&lt;/P&gt;&lt;P&gt; %put &amp;amp;&amp;amp;s&amp;amp;i;&lt;/P&gt;&lt;P&gt;proc import DATAfile= 'F:\phdsas\Book1.xls' out=&amp;amp;&amp;amp;v&amp;amp;I&amp;nbsp; replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; RANGE="&amp;amp;&amp;amp;s&amp;amp;i";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; getnames=NO;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;DATA &amp;amp;&amp;amp;v&amp;amp;I;&lt;/P&gt;&lt;P&gt;SET &amp;amp;&amp;amp;v&amp;amp;I;&lt;/P&gt;&lt;P&gt;CODE="&amp;amp;&amp;amp;v&amp;amp;I";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;proc append base=all data=&amp;amp;&amp;amp;v&amp;amp;I force;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%excelbook;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I wanted to keep the sheet name as a variable called "ticker".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thank you in advance for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 15:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176254#M45196</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-04-10T15:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176255#M45197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps rather than import use the libname to import the dataset and the indsname option?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname D 'F:\phdsas\Book1.xls';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set d.'sheetname$'n indsname=source;&lt;/P&gt;&lt;P&gt;Sheet_Name=source;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 16:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176255#M45197</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-10T16:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176256#M45198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Isn't v1-vn your sheet name stored in code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 16:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176256#M45198</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-10T16:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176257#M45199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes.&lt;/P&gt;&lt;P&gt;In my excel book, the sheet name is the ticker code. So I was wondering if there were a way for me to retain that as a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 19:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176257#M45199</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-04-10T19:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176258#M45200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza,&lt;/P&gt;&lt;P&gt;I will try that and let you know how it goes.&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 19:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176258#M45200</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-04-10T19:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176259#M45201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm confused.&amp;nbsp; Reeza pointed out that you already capture sheet name with a variable called code. Thus, if you just changed the line:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;CODE="&amp;amp;&amp;amp;v&amp;amp;I";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;to&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;ticker="&amp;amp;&amp;amp;v&amp;amp;I";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;I think you would accomplish what you want to do.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 20:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176259#M45201</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-04-10T20:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176260#M45202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Hi everyone,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thank you all for your assistance.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Now it is not working at all.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;The code worked just fine when I have the sheet numbered, but when I am using sheet names with tickers, it is not working at all.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Here is the error code it brings back when I run the code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;For example sheet "AMZG US EQUITY":&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; AMZG US Equity&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 202&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, (, APPENDVER, APPENDVERSION,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BASE, CREATE, DATA, FORCE, GETSORT, NEW, NOWARN, OUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Is there a problem with the sheet name?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 21:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176260#M45202</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-04-10T21:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176261#M45203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Post your full code/log&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 21:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176261#M45203</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-10T21:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176262#M45204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to account for the spaces in your sheet names.&amp;nbsp; That requires changing one line of your code.&amp;nbsp; Try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select distinct(translate(trim(compress(MEMNAME,"'$")),'_',' ')) into: v1 - :v%trim(%left(&amp;amp;tot))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead of:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;select distinct(compress(MEMNAME,"'$")) into: v1 - :v%trim(%left(&amp;amp;tot))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 22:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176262#M45204</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-04-10T22:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176263#M45205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You already have the value in a macro variable just create a new variable to hold the value.&lt;/P&gt;&lt;P&gt;Note that you are working too hard to pull the information into macro variables, you can create them and count them in one step.&lt;/P&gt;&lt;P&gt;Why does the DO loop start at 4 ???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; excelbook(path);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;libname d &amp;amp;path ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;proc sql noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; select memname&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , compress(memname,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"'$"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :s1-:s9999&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , :v1-:v9999&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sashelp.vtable&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'D'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; tot=&amp;amp;sqlobs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;libname d clear;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%to&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;tot;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; SHEET=&amp;amp;&amp;amp;s&amp;amp;i CODE=&amp;amp;&amp;amp;v&amp;amp;i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; proc import datafile=&amp;amp;path out=&amp;amp;&amp;amp;v&amp;amp;i&amp;nbsp; replace;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; range=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"&amp;amp;&amp;amp;s&amp;amp;i"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; getnames=no;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; data &amp;amp;&amp;amp;v&amp;amp;i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length sheet code $&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;32&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sheet=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"&amp;amp;&amp;amp;s&amp;amp;i"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; code=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"&amp;amp;&amp;amp;v&amp;amp;i"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;&amp;amp;v&amp;amp;i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; proc append base=all data=&amp;amp;&amp;amp;v&amp;amp;i force;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; excelbook;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;excelbook&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'f:\phdsas\book1.xls'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 23:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176263#M45205</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-04-10T23:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176264#M45206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Hello Tom,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thanks for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I ran the code you gave me and here is the error message.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;For example for sheet DPW US EQUITY:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DPW US Equity&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 202&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, (, APPENDVER, APPENDVERSION,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BASE, CREATE, DATA, FORCE, GETSORT, NEW, NOWARN, OUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;The do loop starts from 4 because my data is in sheet 4 onward.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Should I change the &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;select memname&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , compress(memname,"'$")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :s1-:s9999&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2014 00:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176264#M45206</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-04-11T00:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176265#M45207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Hello Arthur,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I tried changing the compress(NEMNAME ... bit&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;My full code is now:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro excelbook;&lt;/P&gt;&lt;P&gt;libname D 'F:\phdsas\Book1.xls';&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select count (distinct (memname)) INTO :TOT&lt;/P&gt;&lt;P&gt;from sashelp.vtable&lt;/P&gt;&lt;P&gt;where libname='D' ;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT (memname) into :s1-:s%trim(%left(&amp;amp;tot))&lt;/P&gt;&lt;P&gt;from sashelp.vtable&lt;/P&gt;&lt;P&gt;where libname='D';&lt;/P&gt;&lt;P&gt;select distinct(translate(trim(compress(MEMNAME,"'$")),'_',' ')) into: v1 - :v%trim(%left(&amp;amp;tot))&lt;/P&gt;&lt;P&gt;from sashelp.vtable&lt;/P&gt;&lt;P&gt;where libname='D';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;libname D clear;&lt;/P&gt;&lt;P&gt;%DO I=4 %TO &amp;amp;tot;&lt;/P&gt;&lt;P&gt;%put &amp;amp;&amp;amp;v&amp;amp;i;&lt;/P&gt;&lt;P&gt;%put &amp;amp;&amp;amp;s&amp;amp;i;&lt;/P&gt;&lt;P&gt;proc import DATAfile= 'F:\phdsas\Book1.xls' out=&amp;amp;&amp;amp;v&amp;amp;I&amp;nbsp; replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; RANGE="&amp;amp;&amp;amp;s&amp;amp;i";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; getnames=NO;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;DATA &amp;amp;&amp;amp;v&amp;amp;I;&lt;/P&gt;&lt;P&gt;SET &amp;amp;&amp;amp;v&amp;amp;I;&lt;/P&gt;&lt;P&gt;TICKER="&amp;amp;&amp;amp;v&amp;amp;I";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;proc append base=all data=&amp;amp;&amp;amp;v&amp;amp;I force;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%excelbook;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;The error message I got back is:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference TOT not resolved.&lt;/P&gt;&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operand is required. The condition was: &amp;amp;tot&lt;/P&gt;&lt;P&gt;ERROR: The %TO value of the %DO I loop is invalid.&lt;/P&gt;&lt;P&gt;ERROR: The macro EXCELBOOK will stop executing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2014 00:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176265#M45207</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-04-11T00:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176266#M45208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are not removing the spaces in the sheetnames when you are generating the dataset names.&lt;/P&gt;&lt;P&gt;You need to either add space to the list of characters to compress out of the sheetnames or convert the spaces to other valid character like an underscore.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;compress(memname,"'""$ ")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2014 00:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176266#M45208</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-04-11T00:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176267#M45209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does the xls file still exist or did you change its name or extenstion?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only difference between your and my code is that I included the engine in my libname statement i.e.:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;libname D excel 'c:\phdsas\Book1.xls';&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;However, since it was working for you earlier without declaring the excel engine, I didn't see any reason to include it now.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The only thing I can suggest is to ensure that the excel workbook is still in the specified directory, still has an xls extension, close and start a new SAS session and try running the macro without making any other changes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2014 01:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176267#M45209</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-04-11T01:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176268#M45210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Oh yes it is working now. I had the excel file open so that's probably why I got an error message.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2014 11:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176268#M45210</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-04-11T11:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176269#M45211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Hello Tom,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;The modification worked perfectly! &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thank you!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2014 12:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176269#M45211</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-04-11T12:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Keep excel sheet name as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176270#M45212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thank you all for taking time to answer my question.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Both Arthur's modifications and Tom's code are working perfectly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I will go ahead and give Tom "correct answer" since it has the full code for other people to use.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Again thanks to everyone for your precious assistance!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2014 12:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keep-excel-sheet-name-as-a-variable/m-p/176270#M45212</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-04-11T12:11:47Z</dc:date>
    </item>
  </channel>
</rss>

