<?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: Removing a variable pre-fix within a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412039#M279796</link>
    <description>&lt;P&gt;Hi PaigeMiller,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes you have understood my problem almost exactly. I am trying to remove the prefix altogether. I have tried your method which works fine outside of a macro but once inside I am getting a strange error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; bomi_audit(ds_1=, ds_2=, link_21=, link_23=, link_32=, out=); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;connect to odbc(dsn=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'BOMIN'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;create table &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; as &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select * from connection to odbc&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;SELECT &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;*&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;[dbbommain]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[dbo]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[analytics_population] a&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;left join &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;ds_1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on a.RSI_NO = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_21.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;inner join &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;ds_2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_23.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INNER JOIN&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;(SELECT &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, MAX(modified_date) AS MaxDateTime&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;from [dbbommain]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[dbo]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[analytics_population] a&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;left join &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;ds_1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on a.RSI_NO = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_21.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;inner join &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;ds_2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_23.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHERE cast(modified_date as date) &amp;lt;= inv_start_date&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;GROUP BY &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) grouped_table&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;ON &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;grouped_table.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AND c.modified_date = grouped_table.MaxDateTime;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;disconnect from odbc;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;data &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(keep=NEW: );&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;set &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;select cats(name,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'='&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,tranwrd(name,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'NEW_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;into : prefixlist&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;separated by &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' '&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from dictionary.columns&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;where libname = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"WORK"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; and memname = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;out."&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; and name like &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'NEW_%'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;proc datasets library = work nolist;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;modify &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;rename &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;prefixlist.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; bomi_audit;&lt;/FONT&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error message I am getting is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference PREFIXLIST not resolved.&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "BOMI_AUDIT".&lt;/P&gt;&lt;P&gt;23 rename &amp;amp;prefixlist.; run;&lt;/P&gt;&lt;P&gt;_&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;76&lt;/P&gt;&lt;P&gt;NOTE: Enter RUN; to continue or QUIT; to end the procedure.&lt;/P&gt;&lt;P&gt;MPRINT(BOMI_AUDIT): rename &amp;amp;prefixlist. run;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Expecting a name.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2017 17:20:02 GMT</pubDate>
    <dc:creator>EoghanRussell</dc:creator>
    <dc:date>2017-11-09T17:20:02Z</dc:date>
    <item>
      <title>Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412001#M279790</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Hi Guys.&amp;nbsp;I am trying to rename tables of varying size where the common pre-fix is "New_" I would like to be able to do this without having to specify the number of variables but any method I have tried so far has not worked - including using a&lt;BR /&gt;proc sql &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;select into :list etc to then rename.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;All help appreciated&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Thanks&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; A;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; new_id &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$4.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; new_var1 new_var2 new_var3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i001 1 2 3&lt;/P&gt;&lt;P&gt;i002 3 4 5&lt;/P&gt;&lt;P&gt;i003 6 7 8&lt;/P&gt;&lt;P&gt;i004 9 10 12&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; replaceprefix(out,end);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;set &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%LET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ds=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%SYSFUNC&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(OPEN(temp,i));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ol=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%length&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(NEW_);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;end;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; dsvn&amp;amp;i=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%SYSFUNC&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(VARNAME(&amp;amp;ds,&amp;amp;i));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; l=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%length&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;&amp;amp;dsvn&amp;amp;i);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; vn&amp;amp;i=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%SUBSTR&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;&amp;amp;dsvn&amp;amp;i,&amp;amp;ol+1,&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%EVAL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;l-&amp;amp;ol));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;data &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;set temp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;end;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;amp;&amp;amp;vn&amp;amp;i=&amp;amp;&amp;amp;dsvn&amp;amp;i;&lt;/P&gt;&lt;P&gt;drop &amp;amp;&amp;amp;dsvn&amp;amp;i;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; rc=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%SYSFUNC&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(CLOSE(&amp;amp;ds));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; replaceprefix;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;replaceprefix&lt;/I&gt;&lt;/STRONG&gt;(A,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 16:34:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412001#M279790</guid>
      <dc:creator>EoghanRussell</dc:creator>
      <dc:date>2017-11-09T16:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412017#M279791</link>
      <description>&lt;P&gt;Sorry, what are you trying to do, your post is unclear.&amp;nbsp; If its simply to change variables then a you have many methods available to you, avoid immediately resorting to macro for instance two options, one simple rename of range, the other proc transpose:&lt;/P&gt;
&lt;PRE&gt;data a;
  input new_id $4. new_var1 new_var2 new_var3;
datalines; 
i001 1 2 3
i002 3 4 5
i003 6 7 8
i004 9 10 12
; 
run;
data want;
  set a (rename=(new_var1-new_var3=old_var1-old_var3));
run;

proc transpose data=a out=inter;
  by new_id;
  var new_var:;
run;
proc transpose data=inter out=want2 prefix=old_var;
  by new_id;
  var col1;
run;
&lt;/PRE&gt;
&lt;P&gt;The benefit with the first is simplicity, but you need to know the range, but you could get this from a select into.&amp;nbsp; The transpose is more robust as you can have any number of variables, you don't need to know upfront.&amp;nbsp; There is also arrays which could achieve the same.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 16:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412017#M279791</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-09T16:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412030#M279792</link>
      <description>&lt;P&gt;Hey ladies,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your question is unclear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Are you renaming tables or variables?&lt;/P&gt;
&lt;P&gt;2. Assuming variables, if the prefix is new_ what's it going to be replaced by?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. For renaming you shouldn't recreate the variables, use a RENAME statement with PROC DATASETS instead&lt;/P&gt;
&lt;P&gt;4. Why is 4 in your macro parameter list? Use either PROC CONTENTS or SASHELP.VCOLUMN to get the column names&lt;/P&gt;
&lt;P&gt;5. It really, really, really helps if you both comment and format your code for legibility.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:03:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412030#M279792</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-09T17:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412032#M279793</link>
      <description>&lt;P&gt;Hi RW9. Thank you for the quick response. So the reason I resorted to a macro is I have almost 100 audit tables audit_address, audit_customer etc.&lt;BR /&gt;Each of these tables had a different number of columns i.e.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;audit_address : new_addressline1, new_addressline2.......&lt;BR /&gt;audit_customer: new_surname, new_email, new_phone......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So I need to change these 100+ tables so that the columns names are&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;audit_address : addressline1, addressline2.......&lt;BR /&gt;audit_customer: surname, email, phone......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope this is a bit clearer. Some of these tables have over 50 columns so ideally I don't want to have to write these in manually&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412032#M279793</guid>
      <dc:creator>EoghanRussell</dc:creator>
      <dc:date>2017-11-09T17:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412034#M279794</link>
      <description>&lt;P&gt;So let me see if I understand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have a data set with all variables having a common prefix, such as&lt;/P&gt;
&lt;P&gt;new_1 new_2 new_3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and you want to rename these to some other common prefix such as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;stv_1 stv_2 stv_3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but there depending on the data set, there may be more than 3 variables, or less than 3 variables, or exactly three variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would do a PROC CONTENTS and send the result to a SAS data set, let's call this SAS data set _contents_&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then (UNTESTED CODE)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
     select distinct cats(name,'=stv_',substr(name,5)) into
        :rename_macro_var from _contents_ where lowcase(name) eqt 'new_';
quit;
proc datasets library=work;
    modify dataset;
    rename &amp;amp;rename_macro_var;
run;
quit;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412034#M279794</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-09T17:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412037#M279795</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies - the code is a combination of snippets I have picked up to try resolve my issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Are you renaming tables or variables?&lt;/P&gt;&lt;P&gt;I am renaming the variables not the tables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Assuming variables, if the prefix is new_ what's it going to be replaced by?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to remove the prefix - I gave an example in a previous reply&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. For renaming you shouldn't recreate the variables, use a RENAME statement with PROC DATASETS instead&lt;/P&gt;&lt;P&gt;I had previously used a rename statement but got a different error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select cats(name,'='tranwrd(name,'NEW_',''))&lt;BR /&gt;into : prefixlist&lt;/P&gt;&lt;P&gt;separated by ' '&lt;/P&gt;&lt;P&gt;from dictionary.columns&lt;/P&gt;&lt;P&gt;where libaname = "'WORK" and memname = '&amp;amp;out."&amp;nbsp; /*out is the data set I am modifiying*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc datasets library = work nolist;&lt;/P&gt;&lt;P&gt;modify &amp;amp;out.;&lt;/P&gt;&lt;P&gt;rename &amp;amp;prefixlist.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This although working fine outside a macro is giving me an error around&amp;nbsp; "&lt;SPAN&gt;rename &amp;amp;prefixlist." ERROR 22-322: Expecting a name.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412037#M279795</guid>
      <dc:creator>EoghanRussell</dc:creator>
      <dc:date>2017-11-09T17:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412039#M279796</link>
      <description>&lt;P&gt;Hi PaigeMiller,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes you have understood my problem almost exactly. I am trying to remove the prefix altogether. I have tried your method which works fine outside of a macro but once inside I am getting a strange error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; bomi_audit(ds_1=, ds_2=, link_21=, link_23=, link_32=, out=); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;connect to odbc(dsn=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'BOMIN'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;create table &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; as &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select * from connection to odbc&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;SELECT &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;*&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;[dbbommain]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[dbo]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[analytics_population] a&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;left join &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;ds_1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on a.RSI_NO = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_21.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;inner join &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;ds_2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_23.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INNER JOIN&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;(SELECT &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, MAX(modified_date) AS MaxDateTime&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;from [dbbommain]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[dbo]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[analytics_population] a&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;left join &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;ds_1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on a.RSI_NO = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_21.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;inner join &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;ds_2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_23.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHERE cast(modified_date as date) &amp;lt;= inv_start_date&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;GROUP BY &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) grouped_table&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;ON &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;grouped_table.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;link_32.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AND c.modified_date = grouped_table.MaxDateTime;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;disconnect from odbc;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;data &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(keep=NEW: );&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;set &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;select cats(name,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'='&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,tranwrd(name,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'NEW_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;into : prefixlist&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;separated by &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' '&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from dictionary.columns&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;where libname = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"WORK"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; and memname = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;out."&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; and name like &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'NEW_%'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;proc datasets library = work nolist;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;modify &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;rename &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;prefixlist.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; bomi_audit;&lt;/FONT&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error message I am getting is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference PREFIXLIST not resolved.&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "BOMI_AUDIT".&lt;/P&gt;&lt;P&gt;23 rename &amp;amp;prefixlist.; run;&lt;/P&gt;&lt;P&gt;_&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;76&lt;/P&gt;&lt;P&gt;NOTE: Enter RUN; to continue or QUIT; to end the procedure.&lt;/P&gt;&lt;P&gt;MPRINT(BOMI_AUDIT): rename &amp;amp;prefixlist. run;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Expecting a name.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412039#M279796</guid>
      <dc:creator>EoghanRussell</dc:creator>
      <dc:date>2017-11-09T17:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412043#M279797</link>
      <description>&lt;P&gt;1. Make everything the same case. You're usine NEW_ but your data is new_, that's NOT the same thing in a character value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. same with the WHERE condition, make them all upper case&lt;/P&gt;
&lt;P&gt;3. Your CATS function is wrong&lt;/P&gt;
&lt;P&gt;4. Your quotes are mismatched in the WHERE clause.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. I would recommend you start programming in smaller steps so you can see where your errors are.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let out=A;&lt;BR /&gt;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select catx("=", name,tranwrd(upcase(name),'NEW_',''))&lt;BR /&gt; into : prefixlist&lt;BR /&gt; separated by ' '&lt;BR /&gt;from dictionary.columns&lt;BR /&gt;where %upcase(libname) = %upcase("WORK") and %upcase(memname) = %upcase("&amp;amp;out.") ;&lt;BR /&gt;quit;&lt;BR /&gt; &lt;/PRE&gt;
&lt;P&gt;Try this one for starters.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412043#M279797</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-09T17:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412055#M279798</link>
      <description>&lt;P&gt;Why %upcase and not just plain old upcase?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412055#M279798</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-09T17:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412176#M279799</link>
      <description>&lt;P&gt;This should work (add function upcase)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data OUT    ; 
  NEW_ADDRESSLINE1='B'; NEW_ADDRESSLINE2='A';
run;

proc sql noprint;
  select cats(NAME,'=',tranwrd(NAME,'NEW_',''))
  into :renamelist separated by ' '
  from DICTIONARY.COLUMNS
  where upcase(LIBNAME)="WORK" and upcase(MEMNAME)="OUT" and upcase(NAME) like 'NEW_%';
quit;

proc datasets library = work nolist;
  modify OUT;
  rename &amp;amp;renamelist.;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 23:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412176#M279799</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-11-09T23:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412179#M279800</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;When hitting Dictionary tables the macro %UPCASE works faster I was told once. It does seem to be true from my experience but haven't tested it.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 23:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412179#M279800</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-09T23:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412189#M279801</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;%upcase would be marginally faster as the sql parser won't execute the function for all values.&lt;/P&gt;
&lt;P&gt;You cannot use it for table values though, only for code constants (&lt;FONT face="courier new,courier"&gt;WORK&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;&amp;amp;out&lt;/FONT&gt; here).&lt;/P&gt;
&lt;P&gt;So&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;&lt;BR /&gt;select catx("=", name,tranwrd(upcase(name),'NEW_',''))&lt;BR /&gt; into : prefixlist&lt;BR /&gt; separated by ' '&lt;BR /&gt;from dictionary.columns&lt;BR /&gt;where %upcase(libname) = %upcase("WORK") and %upcase(memname) = %upcase("&amp;amp;out") ;&lt;BR /&gt;quit; &lt;/PRE&gt;
&lt;P&gt;should be&lt;/P&gt;
&lt;PRE&gt;&lt;BR /&gt;where upcase(libname) = %upcase("WORK") and upcase(memname) = %upcase("&amp;amp;out") ;&lt;BR /&gt; &lt;/PRE&gt;
&lt;P&gt;In this example upcase() is just for safety anyway as the dictionary normally returns&amp;nbsp;libnames and memnames (but not var names)&amp;nbsp; upper cased.&lt;/P&gt;
&lt;P&gt;If speed is an issue the dictionary is best avoided and &lt;FONT face="courier new,courier"&gt;proc contents out=&lt;/FONT&gt; is *much* faster in my experience&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 01:42:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412189#M279801</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-11-10T01:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412249#M279802</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;I should probably highlight (and I'm not trying to come across as smart &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ) that the code works fine once outside the Macro - the only issue I am having in once I place it within a macro.&lt;/P&gt;&lt;P&gt;I have made the changes you suggested except around the cats function - can you explain why catx works better than cats please? Also I think you meant&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;catx(name,"=", tranwrd(upcase(name),'NEW_',''))&lt;/PRE&gt;&lt;P&gt;and not&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;catx("=", name,tranwrd(upcase(name),'NEW_',''))&lt;/PRE&gt;&lt;P&gt;am I correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 09:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412249#M279802</guid>
      <dc:creator>EoghanRussell</dc:creator>
      <dc:date>2017-11-10T09:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412252#M279803</link>
      <description>&lt;P&gt;Thanks for all the help guys. Much appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 09:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412252#M279803</guid>
      <dc:creator>EoghanRussell</dc:creator>
      <dc:date>2017-11-10T09:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412392#M279804</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105430"&gt;@EoghanRussell&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;I should probably highlight (and I'm not trying to come across as smart &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ) that the code works fine once outside the Macro - the only issue I am having in once I place it within a macro.&lt;/P&gt;
&lt;P&gt;I have made the changes you suggested except around the cats function - can you explain why catx works better than cats please? Also I think you meant&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;catx(name,"=", tranwrd(upcase(name),'NEW_',''))&lt;/PRE&gt;
&lt;P&gt;and not&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;catx("=", name,tranwrd(upcase(name),'NEW_',''))&lt;/PRE&gt;
&lt;P&gt;am I correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, it works as coded and I had tested it.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412392#M279804</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-10T15:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a variable pre-fix within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412397#M279805</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105430"&gt;@EoghanRussell&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi PaigeMiller,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes you have understood my problem almost exactly. I am trying to remove the prefix altogether. I have tried your method which works fine outside of a macro but once inside I am getting a strange error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; bomi_audit(ds_1=, ds_2=, link_21=, link_23=, link_32=, out=); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;connect to odbc(dsn=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'BOMIN'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;create table &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; as &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select * from connection to odbc&lt;/P&gt;
&lt;P&gt;(&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;SELECT &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;*&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FROM&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;[dbbommain]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[dbo]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[analytics_population] a&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;left join &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;ds_1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on a.RSI_NO = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_21.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;inner join &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;ds_2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_23.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INNER JOIN&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;(SELECT &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, MAX(modified_date) AS MaxDateTime&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;from [dbbommain]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[dbo]&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;[analytics_population] a&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;left join &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;ds_1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on a.RSI_NO = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_21.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;inner join &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;ds_2.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;on &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_23.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHERE cast(modified_date as date) &amp;lt;= inv_start_date&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;GROUP BY &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) grouped_table&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;ON &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;c.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_32.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;grouped_table.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;link_32.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AND c.modified_date = grouped_table.MaxDateTime;&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;disconnect from odbc;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;data &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;out.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(keep=NEW: );&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;set &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;work.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;select cats(name,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'='&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,tranwrd(name,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'NEW_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into : prefixlist&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;separated by &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;' '&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from dictionary.columns&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;where libname = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"WORK"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; and memname = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;out."&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; and name like &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'NEW_%'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;proc datasets library = work nolist;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;modify &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;out.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;rename &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;prefixlist.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; bomi_audit;&lt;/FONT&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message I am getting is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: Apparent symbolic reference PREFIXLIST not resolved.&lt;/P&gt;
&lt;P&gt;NOTE: Line generated by the invoked macro "BOMI_AUDIT".&lt;/P&gt;
&lt;P&gt;23 rename &amp;amp;prefixlist.; run;&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;22&lt;/P&gt;
&lt;P&gt;76&lt;/P&gt;
&lt;P&gt;NOTE: Enter RUN; to continue or QUIT; to end the procedure.&lt;/P&gt;
&lt;P&gt;MPRINT(BOMI_AUDIT): rename &amp;amp;prefixlist. run;&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Expecting a name.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I wonder if this is a capitalization mismatch in this part of your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;where libname = "WORK" and memname = "&amp;amp;out." and name like 'NEW_%';&lt;/PRE&gt;
&lt;P&gt;In the future please type SAS code into the box opened by clicking on the {i} icon.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-variable-pre-fix-within-a-macro/m-p/412397#M279805</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-10T15:50:53Z</dc:date>
    </item>
  </channel>
</rss>

