<?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: replacing special characters in Excel titles in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505311#M1133</link>
    <description>&lt;P&gt;First most thing you need to consider is, &lt;STRONG&gt;How your macro variables are resolved? &lt;/STRONG&gt;set&lt;STRONG&gt; Options SYMBBOLGEN &lt;/STRONG&gt;for this and in the log you can see what file is being imported and what was your output dataset created. Also make sure you give the right &lt;STRONG&gt;dbms=&lt;/STRONG&gt; for xls and xlsx files (both are not same).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the log, I bet your macros are giving an invalid name for the SAS dataset names.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data "APPLES_03-10-2018_(REVENUE).xls"n;
set sashelp.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above code will through you the same error that you got.&amp;nbsp; Check your&amp;nbsp;&lt;STRONG&gt;&amp;amp;&amp;amp;name&amp;amp;i&lt;/STRONG&gt; values and see if that is valid SAS&amp;nbsp; Name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;File names are not causing an issue here and if you still wants to rename all of the file names in a folder then SAS is not the right tool for this.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Oct 2018 19:48:14 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2018-10-17T19:48:14Z</dc:date>
    <item>
      <title>Importing Excel files with macros, not a valid SAS member name</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505200#M1119</link>
      <description>&lt;P&gt;Hello SAS community,&lt;BR /&gt;&lt;BR /&gt;I am having troubles importing excel files from my directory.&lt;BR /&gt;&lt;BR /&gt;I have build a macro that loops through the directory to import the excel files.&lt;BR /&gt;&lt;BR /&gt;However, the titles are inconsistent and some titles are providing a error.&lt;BR /&gt;&lt;BR /&gt;Example of excel files in the directory:&lt;BR /&gt;APPLES_10-09-2018_REVENUE.xlxs&lt;BR /&gt;APPLES_01_01_2017_REVENUE.xlxs&lt;BR /&gt;APPLES_10_01_2017_REVENUE.xlxs&lt;BR /&gt;APPLES_05-06-2017_REVENUE.xlxs&lt;BR /&gt;APPLES_03-10-2018_(REVENUE).xlxs&lt;BR /&gt;&lt;BR /&gt;In this case the - and ( ) characters&amp;nbsp;are giving me a hard time to import them.&lt;BR /&gt;Is it possible to write a code in SAS that can change all - characters of the excel titles to _ and remove ( ) characters ?&lt;BR /&gt;How will that code sort of look like?&lt;BR /&gt;&lt;BR /&gt;your expertise is much welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;The Log + ERROR STATEMENT:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;ERROR: The value 'APPLE_INVOICE_01-07-2018_83274.XLS'n is not a valid SAS member name. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;75 /* This macro imports all files of type1 specified in the&amp;nbsp;folder and save them as datasets */&lt;/P&gt;&lt;P&gt;76 %macro import_loop1;&lt;/P&gt;&lt;P&gt;77 %do i=1 %to &amp;amp;Total;&lt;/P&gt;&lt;P&gt;78 proc import datafile= "&amp;amp;filenm./&amp;amp;&amp;amp;File&amp;amp;i"&lt;/P&gt;&lt;P&gt;79 out= work.&amp;amp;&amp;amp;name&amp;amp;i&lt;/P&gt;&lt;P&gt;80 dbms=XLSX&lt;/P&gt;&lt;P&gt;81 replace;&lt;/P&gt;&lt;P&gt;82 Sheet=&amp;amp;type1sheet;&lt;/P&gt;&lt;P&gt;83 getnames=yes;&lt;/P&gt;&lt;P&gt;84 datarow=2;&lt;/P&gt;&lt;P&gt;85 run;&lt;/P&gt;&lt;P&gt;86&lt;/P&gt;&lt;P&gt;87 %let source= &amp;amp;&amp;amp;name&amp;amp;i;&lt;/P&gt;&lt;P&gt;88 data work.&amp;amp;source;&lt;/P&gt;&lt;P&gt;89 set work.&amp;amp;source;&lt;/P&gt;&lt;P&gt;90 Sourcefile_get = SYMGET('source');&lt;/P&gt;&lt;P&gt;91 Sourcefile = substr(Sourcefile_get, 2,(length (Sourcefile_get)-3));&lt;/P&gt;&lt;P&gt;92 drop Sourcefile_get&lt;/P&gt;&lt;P&gt;93 run;&lt;/P&gt;&lt;P&gt;94&lt;/P&gt;&lt;P&gt;95 proc datasets;&lt;/P&gt;&lt;P&gt;96 append base=work.appended_&amp;amp;filetype1 data=work.&amp;amp;&amp;amp;name&amp;amp;i force;&lt;/P&gt;&lt;P&gt;97 run;&lt;/P&gt;&lt;P&gt;3 The SAS System 20:56 Wednesday, October 17, 2018&lt;/P&gt;&lt;P&gt;98 %end;&lt;/P&gt;&lt;P&gt;99 %mend import_loop1;&lt;/P&gt;&lt;P&gt;100 %import_loop1&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;ERROR: The value 'APPLE_INVOICE_01-07-2018_83274.XLS'n is not a valid SAS member name.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 12:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505200#M1119</guid>
      <dc:creator>Machine_Gan</dc:creator>
      <dc:date>2018-10-24T12:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: replacing special characters in Excel titles</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505251#M1124</link>
      <description>&lt;P&gt;You can still import the excel file if the file name have special characters like dashes and parenthesis. Show us your log and the code your using to import the file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was able to&amp;nbsp;import the following file name successfully.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile="/usr/APPLES_03-10-2018_(REVENUE).xlsx"
	out=test_file
	dbms=xlsx;
	run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 17:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505251#M1124</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-17T17:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: replacing special characters in Excel titles</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505301#M1128</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Thank you for your reply Surya.&lt;BR /&gt;I have updated my post with the error statement and the relevant part of my code.&lt;BR /&gt;&lt;BR /&gt;I still think I need to know how to change the name of excel files in my folder in bulk. this is a usefull skill and probably a solution to my problem.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 19:28:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505301#M1128</guid>
      <dc:creator>Machine_Gan</dc:creator>
      <dc:date>2018-10-17T19:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: replacing special characters in Excel titles</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505311#M1133</link>
      <description>&lt;P&gt;First most thing you need to consider is, &lt;STRONG&gt;How your macro variables are resolved? &lt;/STRONG&gt;set&lt;STRONG&gt; Options SYMBBOLGEN &lt;/STRONG&gt;for this and in the log you can see what file is being imported and what was your output dataset created. Also make sure you give the right &lt;STRONG&gt;dbms=&lt;/STRONG&gt; for xls and xlsx files (both are not same).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the log, I bet your macros are giving an invalid name for the SAS dataset names.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data "APPLES_03-10-2018_(REVENUE).xls"n;
set sashelp.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above code will through you the same error that you got.&amp;nbsp; Check your&amp;nbsp;&lt;STRONG&gt;&amp;amp;&amp;amp;name&amp;amp;i&lt;/STRONG&gt; values and see if that is valid SAS&amp;nbsp; Name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;File names are not causing an issue here and if you still wants to rename all of the file names in a folder then SAS is not the right tool for this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 19:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505311#M1133</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-17T19:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: replacing special characters in Excel titles</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505379#M1151</link>
      <description>&lt;P&gt;The file names shouldn't be problematic unless you're also trying to name the datasets the same name. Or perhaps there's something in your process that's changing them? It would definitely help if you posted your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use COMPRESS() to remove specific characters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/217092"&gt;@Machine_Gan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello SAS community,&lt;BR /&gt;&lt;BR /&gt;I am having troubles importing excel files from my directory.&lt;BR /&gt;&lt;BR /&gt;I have build a macro that loops through the directory to import the excel files.&lt;BR /&gt;&lt;BR /&gt;However, the titles are inconsistent and some titles are providing a error.&lt;BR /&gt;&lt;BR /&gt;Example of excel files in the directory:&lt;BR /&gt;APPLES_10-09-2018_REVENUE.xlxs&lt;BR /&gt;APPLES_01_01_2017_REVENUE.xlxs&lt;BR /&gt;APPLES_10_01_2017_REVENUE.xlxs&lt;BR /&gt;APPLES_05-06-2017_REVENUE.xlxs&lt;BR /&gt;APPLES_03-10-2018_(REVENUE).xlxs&lt;BR /&gt;&lt;BR /&gt;In this case the - and ( ) characters&amp;nbsp;are giving me a hard time to import them.&lt;BR /&gt;Is it possible to write a code in SAS that can change all - characters of the excel titles to _ and remove ( ) characters ?&lt;BR /&gt;How will that code sort of look like?&lt;BR /&gt;&lt;BR /&gt;your expertise is much welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;The Log + ERROR STATEMENT:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;ERROR: The value 'APPLE_INVOICE_01-07-2018_83274.XLS'n is not a valid SAS member name. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;75 /* This macro imports all files of type1 specified in the&amp;nbsp;folder and save them as datasets */&lt;/P&gt;
&lt;P&gt;76 %macro import_loop1;&lt;/P&gt;
&lt;P&gt;77 %do i=1 %to &amp;amp;Total;&lt;/P&gt;
&lt;P&gt;78 proc import datafile= "&amp;amp;filenm./&amp;amp;&amp;amp;File&amp;amp;i"&lt;/P&gt;
&lt;P&gt;79 out= work.&amp;amp;&amp;amp;name&amp;amp;i&lt;/P&gt;
&lt;P&gt;80 dbms=XLSX&lt;/P&gt;
&lt;P&gt;81 replace;&lt;/P&gt;
&lt;P&gt;82 Sheet=&amp;amp;type1sheet;&lt;/P&gt;
&lt;P&gt;83 getnames=yes;&lt;/P&gt;
&lt;P&gt;84 datarow=2;&lt;/P&gt;
&lt;P&gt;85 run;&lt;/P&gt;
&lt;P&gt;86&lt;/P&gt;
&lt;P&gt;87 %let source= &amp;amp;&amp;amp;name&amp;amp;i;&lt;/P&gt;
&lt;P&gt;88 data work.&amp;amp;source;&lt;/P&gt;
&lt;P&gt;89 set work.&amp;amp;source;&lt;/P&gt;
&lt;P&gt;90 Sourcefile_get = SYMGET('source');&lt;/P&gt;
&lt;P&gt;91 Sourcefile = substr(Sourcefile_get, 2,(length (Sourcefile_get)-3));&lt;/P&gt;
&lt;P&gt;92 drop Sourcefile_get&lt;/P&gt;
&lt;P&gt;93 run;&lt;/P&gt;
&lt;P&gt;94&lt;/P&gt;
&lt;P&gt;95 proc datasets;&lt;/P&gt;
&lt;P&gt;96 append base=work.appended_&amp;amp;filetype1 data=work.&amp;amp;&amp;amp;name&amp;amp;i force;&lt;/P&gt;
&lt;P&gt;97 run;&lt;/P&gt;
&lt;P&gt;3 The SAS System 20:56 Wednesday, October 17, 2018&lt;/P&gt;
&lt;P&gt;98 %end;&lt;/P&gt;
&lt;P&gt;99 %mend import_loop1;&lt;/P&gt;
&lt;P&gt;100 %import_loop1&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;ERROR: The value 'APPLE_INVOICE_01-07-2018_83274.XLS'n is not a valid SAS member name.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 22:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/505379#M1151</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-17T22:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: replacing special characters in Excel titles</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/507114#M1430</link>
      <description>&lt;P&gt;thank you,&lt;BR /&gt;&lt;BR /&gt;I have solved my issue by working around the name. the issue is that &amp;amp;&amp;amp;name&amp;amp;i is not a valid sas name. So I couldn't use it for naming my dataset.&lt;BR /&gt;I now use &amp;amp;I as dataset name and have used symget(&amp;amp;&amp;amp;name&amp;amp;i) to add a variable to the dataset to indentify the file&amp;nbsp;origin&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 12:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-Excel-files-with-macros-not-a-valid-SAS-member-name/m-p/507114#M1430</guid>
      <dc:creator>Machine_Gan</dc:creator>
      <dc:date>2018-10-24T12:34:27Z</dc:date>
    </item>
  </channel>
</rss>

