<?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: Problem use libname with excel file in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91978#M26216</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;'$' is not allow in SAS naming convention, along with space, ',' and many other special symbols. if you run into names like that , a SAS literal has to be used. A simple way to convert it is to use nliteral(), which is also a way to make sure it complies with naming convention:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;a='sheet1$';&lt;/P&gt;&lt;P&gt;a1='sheet';&lt;/P&gt;&lt;P&gt;b1=nliteral(a1);&lt;/P&gt;&lt;P&gt;b=nliteral(a);&lt;/P&gt;&lt;P&gt;put b= b1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Aug 2012 20:55:08 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-08-13T20:55:08Z</dc:date>
    <item>
      <title>Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91974#M26212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a excel file named all.xls, in the excel file there are three sheets named sheetone,sheettwo and sheetthree&lt;/P&gt;&lt;P&gt;When after I use libname engine: libname xl&amp;nbsp;&amp;nbsp; "c:\temp\all.xls";&lt;/P&gt;&lt;P&gt;I can treat each individual sheet as SAS table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the problem is the Sheet's name will be changed with an additional '$' symbol,,,,,sucha as sheetone will be changed to sheetone$.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I can open to preview the dataset but can't create other datast use this,such as if I use :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sheetone;&lt;/P&gt;&lt;P&gt;set xl.sheetone$;/*I also try set xl.sheetone,still not work*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;this will cause error:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: File XL.sheetone$.DATA does not exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, ;, END,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so how I cloud make use this dataset?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 17:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91974#M26212</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-08-13T17:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91975#M26213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;data sheetone;&lt;/P&gt;&lt;P&gt;set xl."sheetone$"n;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 18:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91975#M26213</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-08-13T18:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91976#M26214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Instead of 'set xl.sheetone$;', try this: set xl.'sheetone$'n;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 18:10:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91976#M26214</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-13T18:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91977#M26215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any help information I coud find for this solution? what does the "n" means?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:36:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91977#M26215</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-08-13T20:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91978#M26216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;'$' is not allow in SAS naming convention, along with space, ',' and many other special symbols. if you run into names like that , a SAS literal has to be used. A simple way to convert it is to use nliteral(), which is also a way to make sure it complies with naming convention:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;a='sheet1$';&lt;/P&gt;&lt;P&gt;a1='sheet';&lt;/P&gt;&lt;P&gt;b1=nliteral(a1);&lt;/P&gt;&lt;P&gt;b=nliteral(a);&lt;/P&gt;&lt;P&gt;put b= b1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91978#M26216</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-13T20:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91979#M26217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use Hai.huo's technique to copy all sheets like&lt;/P&gt;&lt;P&gt;libname xl 'your.xls' ;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt;create table xnames as&lt;/P&gt;&lt;P&gt;select memname, nLiteral( memname ) as newName&lt;/P&gt;&lt;P&gt;&amp;nbsp; from dictionary.members&lt;/P&gt;&lt;P&gt; where libname = 'XL' and memname ? '$'&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit ;&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;set xnames ;&lt;/P&gt;&lt;P&gt;call execute( 'proc append base=work.' !! newName );&lt;/P&gt;&lt;P&gt;call execute( ' data= xl.' !! quote(trim(memname)) !! 'n ; run;' );&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;using proc append is a convenient way of copying a data set, but beware of re-running within the same sas session or you might double up the rows of your data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;peterC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 21:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91979#M26217</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2012-08-13T21:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91980#M26218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not put it all into a macro variable ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt;select cats('XL.',nLiteral( memname ) ) into : list separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp; from dictionary.members&lt;/P&gt;&lt;P&gt; where libname = 'XL' &lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit ;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt; set &amp;amp;list ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 04:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91980#M26218</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-08-14T04:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91981#M26219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thank you ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but&amp;nbsp; errors happened when run the code&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;set xnames ;&lt;/P&gt;&lt;P&gt;call execute( 'proc append base=work.' !! newName );&lt;/P&gt;&lt;P&gt;call execute( ' data= xl.' !! quote(trim(memname)) !! 'n ; run;' );&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: The value 'SHEET1$'n is not a valid SAS name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 21:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91981#M26219</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-08-14T21:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91982#M26220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike: I haven't followed this thread.&amp;nbsp; Are you just trying to append all of the sheets into one sas file?&amp;nbsp; If so, the error you are getting is because the code is trying to do something else.&amp;nbsp; Does the minor change, below, do what you wanted?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname xl 'c:\have.xls' ;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table xnames as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select memname, nLiteral( memname ) as newName&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.members&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname = 'XL' and memname ? '$'&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set xnames ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute( 'proc append base=work.want' ); /*&amp;lt;- the one change */&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute( ' data= xl.' !! quote(trim(memname)) !! 'n ; run;' );&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 22:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91982#M26220</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-14T22:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91983#M26221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;maybe you have to add the system option&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; option validvarname= any ;&lt;/P&gt;&lt;P&gt;and I would recommend resetting that after the collection has completed, to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; option validvarname= v8 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Peter Crawford&#xD;
and if that does not work, please post a section of the log showing the generated code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 06:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91983#M26221</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2012-08-15T06:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91984#M26222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;P&gt;I was trying to generate for each tabname$, the syntax&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc append data= xl."tabname$"n&lt;/P&gt;&lt;P&gt; base= work.%sysfunc(nliteral( tabname$ )) ; run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;of course, wrapped in call execute() the nliteral() function appears without %sysfunc()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ArtC's suggestion is equally valid&lt;/P&gt;&lt;P&gt;data work.%sysfunc(nliteral( tabname$ )) ;&lt;/P&gt;&lt;P&gt;set xl."tabname$"n ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 06:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91984#M26222</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2012-08-15T06:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem use libname with excel file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91985#M26223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike: or, if you actually want separate files created in the work directory, couldn't you just compress out the offending characters.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname xl 'c:\have.xls' ;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table xnames as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select memname, nLiteral( memname ) as newName&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.members&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname = 'XL' and memname ? '$'&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set xnames ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute( 'proc append base=work.'||compress(memname,"$ " )); /*&amp;lt;- the one change */&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute( ' data= xl.' !! quote(trim(memname)) !! 'n ; run;' );&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname xl clear;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 13:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-use-libname-with-excel-file/m-p/91985#M26223</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-15T13:03:34Z</dc:date>
    </item>
  </channel>
</rss>

