<?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: Pass strings with special characters as input to macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284356#M58037</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;, Thanks, but what if multiple parameters need to be given as input such as in the following case&lt;BR /&gt;%conmd(pdrug=T|P|C|A|R, dset=ta ,flg=tac);</description>
    <pubDate>Thu, 14 Jul 2016 14:43:12 GMT</pubDate>
    <dc:creator>ari</dc:creator>
    <dc:date>2016-07-14T14:43:12Z</dc:date>
    <item>
      <title>Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284276#M58008</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to run a macro with the following input and it works perfect.&lt;/P&gt;&lt;P&gt;%medc(pdrug=drp1|drp2|drp3|drrp4, dset=data1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, if any special characters in the input such as the following, the macro doesnt work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%medc(pdrug=&lt;STRONG&gt;drp1 w/drp5&lt;/STRONG&gt;|drp2|&lt;STRONG&gt;drp3 w/drp5/drp6/drp7&lt;/STRONG&gt;|drp4, dset=data1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any idea to let the macro recognise these special characters?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 09:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284276#M58008</guid>
      <dc:creator>ari</dc:creator>
      <dc:date>2016-07-14T09:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284277#M58009</link>
      <description>&lt;P&gt;'/' ' ' are special characters for macro device , you need mask them via %str()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%medc(pdrug=%str(&lt;/SPAN&gt;&lt;STRONG&gt;drp1 w/drp5&lt;/STRONG&gt;&lt;SPAN&gt;|drp2|&lt;/SPAN&gt;&lt;STRONG&gt;drp3 w/drp5/drp6/drp7&lt;/STRONG&gt;&lt;SPAN&gt;|drp4) , dset=data1);&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 09:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284277#M58009</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-14T09:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284278#M58010</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;: Thanks for the quick response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, program end up with follwoing error.&lt;/P&gt;&lt;P&gt;ERROR: The regular expression passed to the function PRXMATCH contains a syntax error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 10:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284278#M58010</guid>
      <dc:creator>ari</dc:creator>
      <dc:date>2016-07-14T10:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284284#M58012</link>
      <description>&lt;P&gt;Is there a need to pass them as a macro paramter? &amp;nbsp;Why not pass in a dataset with your list of parameters - it doesn't matter then how long your parameters are or what they contain. &amp;nbsp;If you can provide some test data (form of a datastep) and what the output should like like I can show you.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 10:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284284#M58012</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-14T10:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284289#M58015</link>
      <description>&lt;P&gt;I need to provide input as macro parameter to create datasets based on the match&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro medc(str=,dset=,);&lt;BR /&gt;data &amp;amp;dset;&lt;BR /&gt;set data;&lt;BR /&gt;if prxmatch("m/&amp;amp;pdrug/oi", code)&amp;gt;0;&lt;BR /&gt;run;&lt;BR /&gt;%mend medc;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 11:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284289#M58015</guid>
      <dc:creator>ari</dc:creator>
      <dc:date>2016-07-14T11:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284315#M58020</link>
      <description>&lt;P&gt;So, just as an example there (note, this is just a demo - it doesn't run, you need to update with your data/variables etc.):&lt;/P&gt;
&lt;PRE&gt;data parameters;
  param="abc"; output;
  param="def"; output;
run;

%macro your_macro (ds=);
  proc sql;
    create table WANT as
    select   A.VARIABLES,
             B.VARIABLES
    from     BASE_DATASET A
    left join &amp;amp;DS. B
    on        prxmatch(B.PARAM,A.CODE);
  quit;
%mend your_macro;

%your_macro (ds=parameters);
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 13:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284315#M58020</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-14T13:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284356#M58037</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;, Thanks, but what if multiple parameters need to be given as input such as in the following case&lt;BR /&gt;%conmd(pdrug=T|P|C|A|R, dset=ta ,flg=tac);</description>
      <pubDate>Thu, 14 Jul 2016 14:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284356#M58037</guid>
      <dc:creator>ari</dc:creator>
      <dc:date>2016-07-14T14:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284362#M58038</link>
      <description>&lt;P&gt;I don't know much of the PRX world, but it looks to me like your problem is with the regular expression, not the macro language.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you remove the macro language, can you get the regular expression to work?&amp;nbsp; It looks to me like your current macro would generate the below code, which fails with that error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;39   data want;
40   set sashelp.class;
41   if prxmatch("m/drp1 w/drp5|drp2|drp3 w/drp5/drp6/drp7|drp4/oi", name)&amp;gt;0;
42   run;

ERROR: Invalid characters "drp5|drp2|drp3 w/drp5/drp6/drp7|drp4/oi" after end delimiter "/" of
       regular expression "m/drp1 w/drp5|drp2|drp3 w/drp5/drp6/drp7|drp4/oi".
ERROR: The regular expression passed to the function PRXMATCH contains a syntax error.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So maybe those blanks in your expression are a problem?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Often the first step of macro-debugging is figuring out whether it is the macro language throwing an error or the SAS language.&amp;nbsp; And it often helps to back out of the macro language so that you figure out the SAS code that works first, then figure out how to use the macro language to generate that SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 14:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284362#M58038</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-07-14T14:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284365#M58039</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/82839"&gt;@ari&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;: Thanks for the quick response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, program end up with follwoing error.&lt;/P&gt;
&lt;P&gt;ERROR: The regular expression passed to the function PRXMATCH contains a syntax error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please show the macro call you used and the macro code. The log generated with Options MPRINT may be helpful as well.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 15:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284365#M58039</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-14T15:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284366#M58040</link>
      <description>&lt;P&gt;As always there is many ways of of doing it, you could just replace the list with the dataset, you could put all parameters in the dataset etc.&lt;/P&gt;
&lt;PRE&gt;%conmd(pdrug=params, dset=ta ,flg=tac);&lt;/PRE&gt;
&lt;P&gt;Or, all params in a dataset:&lt;/P&gt;
&lt;PRE&gt;data params:
  param="Values"; item="T"; output;
  param="Values"; item="P": output;
  param="Dset"; item="ta"; output;
  param="Flg"; item="tac"; output;
run;

%macro temp (params=);
...
%mend temp;

%temp (params=params);
&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jul 2016 15:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284366#M58040</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-14T15:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284699#M58091</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;, this solution works but I have lot (&amp;gt;500) of strings to pass as input to macro, any idea to make this script work in this case??</description>
      <pubDate>Thu, 14 Jul 2016 21:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284699#M58091</guid>
      <dc:creator>ari</dc:creator>
      <dc:date>2016-07-14T21:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284706#M58096</link>
      <description>%macro medc(str=,dset=,);&lt;BR /&gt;data &amp;amp;dset;&lt;BR /&gt;set data;&lt;BR /&gt;if prxmatch("m/&amp;amp;pdrug/oi", code)&amp;gt;0;&lt;BR /&gt;run;&lt;BR /&gt;%mend medc;&lt;BR /&gt;&lt;BR /&gt;macro call: %medc(pdrug=drp1 w/drp5|drp2|drp3 w/drp5/drp6/drp7|drp4, dset=data1);&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Jul 2016 23:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284706#M58096</guid>
      <dc:creator>ari</dc:creator>
      <dc:date>2016-07-14T23:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Pass strings with special characters as input to macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284711#M58098</link>
      <description>&lt;P&gt;'/' is keyword for PRX , you need add escape char '\' before it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data data;&lt;BR /&gt;code='drp1 w/drp5';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro medc(pdrug=,dset=,);&lt;BR /&gt;data &amp;amp;dset;&lt;BR /&gt;set data;&lt;BR /&gt;if prxmatch("m/&amp;amp;pdrug/oi", code)&amp;gt;0;&lt;BR /&gt;run;&lt;BR /&gt;%mend medc;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%medc(pdrug=drp1 w\/drp5|drp2|drp3 w\/drp5\/drp6\/drp7|drp4, dset=data1)&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2016 00:50:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-strings-with-special-characters-as-input-to-macro/m-p/284711#M58098</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-15T00:50:13Z</dc:date>
    </item>
  </channel>
</rss>

