<?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: A symbol is not recognized and will be ignored. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860559#M82513</link>
    <description>&lt;P&gt;A CSV file is just a file. It can have any name it wants.&amp;nbsp; But a SAS dataset's name has to follow SAS's rules.&lt;/P&gt;
&lt;P&gt;So just generate a valid SAS name to use as the dataset member name.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST.ABC_POST;
  infile "&amp;amp;DATA_PATH.CSV files/ABC-POST.csv" dsd firstobs=2 truncover;
  length var1 8 var_next $32 .... var_last 8;
  input var1 -- var_last;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you can't find one just use a number.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards truncover;
  length row 8 memname $32 filename $256 ;
  row+1;
  input filename $256.;
  memname=scan(filename,-2,'./\');
  if not nvalid(memname,'v7') then memname=cats('csv',row);
cards;
&amp;amp;DATA_PATH.CSV files/ABC-POST.csv
normal.csv
this_name_is_going_to_be_way_too_long_to_use_as_dataset_name.csv
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1677183552644.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80791i28E04BF207DFCD1B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1677183552644.png" alt="Tom_0-1677183552644.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Feb 2023 20:19:33 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-02-23T20:19:33Z</dc:date>
    <item>
      <title>A symbol is not recognized and will be ignored.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860555#M82512</link>
      <description>&lt;P&gt;Hi, I ran the following code and the symbol "-" is not recognized. I cannot change it since I am importing more than 100 csv files with the symbol "-" in most of the file names. Is there a way for SAS to recognize the symbol?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data TEST.ABC-POST;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile "&amp;amp;DATA_PATH.CSV files/ABC-POST.csv" delimiter=','
...
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the log:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;207        
 208        
 209        *ABC-POST variables;
 210        data TEST.ABC-POST;
                           _
                           22
                           200
 ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.  
 
 ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 20:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860555#M82512</guid>
      <dc:creator>ANKH1</dc:creator>
      <dc:date>2023-02-23T20:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: A symbol is not recognized and will be ignored.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860559#M82513</link>
      <description>&lt;P&gt;A CSV file is just a file. It can have any name it wants.&amp;nbsp; But a SAS dataset's name has to follow SAS's rules.&lt;/P&gt;
&lt;P&gt;So just generate a valid SAS name to use as the dataset member name.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST.ABC_POST;
  infile "&amp;amp;DATA_PATH.CSV files/ABC-POST.csv" dsd firstobs=2 truncover;
  length var1 8 var_next $32 .... var_last 8;
  input var1 -- var_last;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you can't find one just use a number.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards truncover;
  length row 8 memname $32 filename $256 ;
  row+1;
  input filename $256.;
  memname=scan(filename,-2,'./\');
  if not nvalid(memname,'v7') then memname=cats('csv',row);
cards;
&amp;amp;DATA_PATH.CSV files/ABC-POST.csv
normal.csv
this_name_is_going_to_be_way_too_long_to_use_as_dataset_name.csv
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1677183552644.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80791i28E04BF207DFCD1B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1677183552644.png" alt="Tom_0-1677183552644.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 20:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860559#M82513</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-23T20:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: A symbol is not recognized and will be ignored.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860561#M82514</link>
      <description>&lt;P&gt;Ok, so manually change in the SAS datasets' names the "-" to "_". I didn't understand your second option. What do you mean if I cannot find one just use a number? Sorry, I'm new to programming.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 20:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860561#M82514</guid>
      <dc:creator>ANKH1</dc:creator>
      <dc:date>2023-02-23T20:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: A symbol is not recognized and will be ignored.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860568#M82515</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226521"&gt;@ANKH1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ok, so manually change in the SAS datasets' names the "-" to "_". I didn't understand your second option. What do you mean if I cannot find one just use a number? Sorry, I'm new to programming.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You mentioned you wanted to convert a LOT of files.&amp;nbsp; So rather than generating all of that code manually you could use a PROGRAM to read the list of files and generate the code.&amp;nbsp; So how is the PROGRAM going to know what is a valid SAS name to use for any given CSV filename?&amp;nbsp; One way is to not even try, instead just number the files and use the number to generate the names.&amp;nbsp; So the first file could be used to create a dataset named CSV1 and the second file to create a dataset named CSV2.&amp;nbsp; You could actually use the original filename as the label or part of the label for the dataset to help you find the right dataset later.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data csv1(label="Strange file - name.csv");
  infile "Strange file - name.csv" dsd firstobs=2 truncover;
   ...
run;
data csv2(label="Another strange file - name.csv");
  infile "Another strange file - name.csv" dsd firstobs=2 truncover;
   ...
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example of logic I used in the &lt;A href="https://github.com/sasutils/macros/blob/master/csv2ds.sas" target="_self"&gt;%csv2ds()&lt;/A&gt; macro to make sure each name is valid.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if you can figure out from reading the help for the functions used what it is doing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Replace adjacent non-valid characters with single underscore ;
    name=translate(trim(prxchange('s/([^a-zA-Z0-9]+)/ /',-1,name)),' _','_ ');
    name=prxchange('s/(^[0-9])/_$1/',1,name);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Feb 2023 21:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860568#M82515</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-23T21:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: A symbol is not recognized and will be ignored.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860569#M82516</link>
      <description>Your code as shown is invalid and will not work. You cannot place multiple file paths  in the infile statement in this method. &lt;BR /&gt;&lt;BR /&gt;Instead, you can create a data set with the list of files to be read, so it contains the filepath and/or file name. Then within that file, you can check if the dataset name is a valid SAS data set name. If not, you can change it there. &lt;BR /&gt;Then you can use that dataset to generate appropriate SAS code to read each file. &lt;BR /&gt;&lt;BR /&gt;When you're starting out a process like this, the best approach is to first read a few files manually to ensure your code is correct and then figure out how to generalize it for all your files.</description>
      <pubDate>Thu, 23 Feb 2023 21:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-symbol-is-not-recognized-and-will-be-ignored/m-p/860569#M82516</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-02-23T21:16:21Z</dc:date>
    </item>
  </channel>
</rss>

