<?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: Error in SAS macro due to special characters in a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839915#M332080</link>
    <description>Thank you very much Tom!</description>
    <pubDate>Fri, 21 Oct 2022 12:44:17 GMT</pubDate>
    <dc:creator>Haemoglobin17</dc:creator>
    <dc:date>2022-10-21T12:44:17Z</dc:date>
    <item>
      <title>Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839325#M331875</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;I am studying the macro 1 course and I am doing the exercise m104p01. Unfortunately, when I run it, the program produces a table of 12 obs, then stops and it give me the two following error messages:&lt;/P&gt;&lt;DIV class=""&gt;ERROR: Invalid characters were present in the data.&lt;/DIV&gt;&lt;DIV class=""&gt;ERROR: An error occurred while processing text data.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I discovered that the observation the caused this error (that would e the 13th) is one in which the variable name contains an invalid character (I suppose an accent or something like this). As a confirm, If I create a database and I change all the values of name with "Iron Man" it runs perfectly. I was wondering if you know some tricks that helps me to force SAS to accept this special characters. Below you can find the code of the exercise. Thank you all&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* Part b. */&lt;BR /&gt;%macro customers(type); &lt;BR /&gt;title "&amp;amp;type Customers"; &lt;BR /&gt;proc sql number;&lt;BR /&gt;select Name, Age_Group, Type &lt;BR /&gt;    from mc1.customers &lt;BR /&gt;    where Type contains "&amp;amp;type"; &lt;BR /&gt;quit; &lt;BR /&gt;title;&lt;BR /&gt;%mend customers;&lt;BR /&gt;&lt;BR /&gt;%customers(Gold)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 10:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839325#M331875</guid>
      <dc:creator>Haemoglobin17</dc:creator>
      <dc:date>2022-10-19T10:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839338#M331882</link>
      <description>&lt;P&gt;It would help (now, and 100% of the time in the future) for you to show us the ENTIRE log for this macro. Please first turn on macro debugging options by running this command:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint symbolgen;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then, run the macro again, copy the ENTIRE log as text, and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon. Do NOT show us partial logs.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1663012019648.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75161i0E71B1489A6C9839/image-size/large?v=v2&amp;amp;px=999" role="button" title="PaigeMiller_0-1663012019648.png" alt="PaigeMiller_0-1663012019648.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 11:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839338#M331882</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-19T11:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839361#M331893</link>
      <description>&lt;P&gt;Hi PaigeMiller,&lt;/P&gt;&lt;P&gt;Thank you for the answer and for the advice! This is the log that I receive:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;/DIV&gt;&lt;DIV class=""&gt;SYMBOLGEN: Macro variable GRAPHINIT resolves to GOPTIONS RESET=ALL GSFNAME=_GSFNAME;&lt;/DIV&gt;&lt;DIV class=""&gt;68&lt;/DIV&gt;&lt;DIV class=""&gt;69&lt;/DIV&gt;&lt;DIV class=""&gt;70 options mprint symbolgen;&lt;/DIV&gt;&lt;DIV class=""&gt;SYMBOLGEN: Macro variable TYPE resolves to Gold&lt;/DIV&gt;&lt;DIV class=""&gt;71&lt;/DIV&gt;&lt;DIV class=""&gt;72 %customers(Gold)&lt;/DIV&gt;&lt;DIV class=""&gt;MPRINT(CUSTOMERS): title "Gold Customers";&lt;/DIV&gt;&lt;DIV class=""&gt;MPRINT(CUSTOMERS): proc sql number;&lt;/DIV&gt;&lt;DIV class=""&gt;SYMBOLGEN: Macro variable TYPE resolves to Gold&lt;/DIV&gt;&lt;DIV class=""&gt;MPRINT(CUSTOMERS): select Name, Age_Group, Type from mc1.customers where Type contains "Gold";&lt;/DIV&gt;&lt;DIV class=""&gt;ERROR: Invalid characters were present in the data.&lt;/DIV&gt;&lt;DIV class=""&gt;ERROR: An error occurred while processing text data.&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;/DIV&gt;&lt;DIV class=""&gt;MPRINT(CUSTOMERS): quit;&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/DIV&gt;&lt;DIV class=""&gt;real time 0.02 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;user cpu time 0.02 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;system cpu time 0.00 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;memory 5737.18k&lt;/DIV&gt;&lt;DIV class=""&gt;OS Memory 30632.00k&lt;/DIV&gt;&lt;DIV class=""&gt;Timestamp 19/10/2022 12:28:39 PM&lt;/DIV&gt;&lt;DIV class=""&gt;Step Count 46 Switch Count 0&lt;/DIV&gt;&lt;DIV class=""&gt;Page Faults 0&lt;/DIV&gt;&lt;DIV class=""&gt;Page Reclaims 108&lt;/DIV&gt;&lt;DIV class=""&gt;Page Swaps 0&lt;/DIV&gt;&lt;DIV class=""&gt;Voluntary Context Switches 6&lt;/DIV&gt;&lt;DIV class=""&gt;Involuntary Context Switches 0&lt;/DIV&gt;&lt;DIV class=""&gt;Block Input Operations 0&lt;/DIV&gt;&lt;DIV class=""&gt;Block Output Operations 0&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;MPRINT(CUSTOMERS): title;&lt;/DIV&gt;&lt;DIV class=""&gt;73&lt;/DIV&gt;&lt;DIV class=""&gt;74 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class=""&gt;SYMBOLGEN: Macro variable GRAPHTERM resolves to GOPTIONS NOACCESSIBLE;&lt;/DIV&gt;&lt;DIV class=""&gt;84&lt;/DIV&gt;&lt;PRE class=""&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 12:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839361#M331893</guid>
      <dc:creator>Haemoglobin17</dc:creator>
      <dc:date>2022-10-19T12:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839364#M331895</link>
      <description>&lt;P&gt;Please don't ignore the instructions that I gave, about using the &amp;lt;/&amp;gt; icon.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, unfortunately, in this case, the full log isn't any more helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please show us a screen capture of that variable in the 13th record? Use the "Insert Photos" icon to include your screen capture in your reply, do not attach files.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 12:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839364#M331895</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-19T12:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839371#M331897</link>
      <description>&lt;P&gt;Interesting, from a quick google search of the error message, it looks like this is an encoding problems (i.e. the encoding of your session doesn't match the encoding of the data, and SAS isn't able to transcode the values).&amp;nbsp; &amp;nbsp;See e.g.&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Studio/ERROR-Invalid-characters-were-present-in-the-data/td-p/556840" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Studio/ERROR-Invalid-characters-were-present-in-the-data/td-p/556840&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to double check that it's not a macro problem, I would try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql number;
select Name, Age_Group, Type 
    from mc1.customers 
    where Type contains "Gold"; 
quit; 

data want ;
  set mc1.customers ;
  where Type contains "Gold"; 
run ;

proc sql number;
select Name, Age_Group, Type 
    from mc1.customers ;
quit; 

data want ;
  set mc1.customers ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I wonder if it is the WHERE clause that is having the problem.&amp;nbsp; Do the above examples without the WHERE clause/statement work?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 13:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839371#M331897</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-10-19T13:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839592#M331958</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76376iF8C6D4E37B1F06AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; Hi PaigeMiller,&lt;/P&gt;&lt;P&gt;Thank you, I have uploaded a screenshot of part of the database from Sashelp I have been working with. The program stops while evaluating the row 31, that, according to the where statement, should be put in the output dataset. If I change the value of the name it doesn't happens.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 08:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839592#M331958</guid>
      <dc:creator>Haemoglobin17</dc:creator>
      <dc:date>2022-10-20T08:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839593#M331959</link>
      <description>&lt;P&gt;Hi Quentin!&lt;/P&gt;&lt;P&gt;Thank you very much for the replay! I run the program and the error occurs both if the script with the where statement and that without. I thinks that the cause could be the presence of non recognized symbols in the variable name, because when I change these values the problem disappears!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 08:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839593#M331959</guid>
      <dc:creator>Haemoglobin17</dc:creator>
      <dc:date>2022-10-20T08:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839646#M331976</link>
      <description>&lt;P&gt;Can you submit:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %sysfunc(getoption(encoding)) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and post what you get back in the log?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you're right, the problem is likely the special characters in some of the values.&amp;nbsp; &amp;nbsp;If you're SAS session is using the wrong encoding, it may not be able to interpret them.&amp;nbsp; When you start the SAS session, you can choose an encoding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you running SAS?&amp;nbsp; Is this local SAS on your PC, or SAS on a server, or Viya?&amp;nbsp; Is it SAS On Demand for Academics?&amp;nbsp; Depending on how you are running it, you may have varying levels of control over the encoding.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 13:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839646#M331976</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-10-20T13:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839648#M331977</link>
      <description>&lt;P&gt;Either fix the dataset encoding, the SAS session encoding, or tell SAS to ignore the encoding.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select Name, Age_Group, Type 
    from mc1.customers (encoding='any')
    where Type contains "&amp;amp;type"
; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Oct 2022 13:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839648#M331977</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-20T13:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839891#M332064</link>
      <description>&lt;P&gt;If your SAS session runs with UTF encoding, but the data contains single-byte WLATIN9 "special characters", those can be invalid, as they are only allowed as UTF continuation bytes.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 11:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839891#M332064</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-21T11:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error in SAS macro due to special characters in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839915#M332080</link>
      <description>Thank you very much Tom!</description>
      <pubDate>Fri, 21 Oct 2022 12:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-SAS-macro-due-to-special-characters-in-a-variable/m-p/839915#M332080</guid>
      <dc:creator>Haemoglobin17</dc:creator>
      <dc:date>2022-10-21T12:44:17Z</dc:date>
    </item>
  </channel>
</rss>

