<?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: What's wrong with this SAS macro code? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/What-s-wrong-with-this-SAS-macro-code/m-p/508084#M1598</link>
    <description>&lt;P&gt;Make it a habit to always end macro variable references with a dot, and use double quotes for strings where macro variables need to be resolved:&lt;/P&gt;
&lt;PRE&gt;"C:\Users\...\&amp;amp;reg._&amp;amp;typ._&amp;amp;i..xlsx"&lt;/PRE&gt;
&lt;P&gt;Without the dot, the macro preprocessor tries to find macro variable reg_ instead of just reg. Note the double dot: one terminates the reference to &amp;amp;i, the other one stays in the string and goes into the filename.&lt;/P&gt;
&lt;P&gt;Do the same throughout your macro wherever you reference the macro variables.&lt;/P&gt;</description>
    <pubDate>Sun, 28 Oct 2018 07:32:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-10-28T07:32:34Z</dc:date>
    <item>
      <title>What's wrong with this SAS macro code?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/What-s-wrong-with-this-SAS-macro-code/m-p/508083#M1597</link>
      <description>&lt;P&gt;I have 2 files EU_CB_1 and EU_CB_2 in xlsx format. I want to import, append and format these 2 files using macro. I fail to understand why I get errors. Would you please help me identify the error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro impcol (reg,typ,start,count);
%do i=&amp;amp;start %to &amp;amp;count;
proc import datafile='C:\Users\...\&amp;amp;reg_&amp;amp;typ_&amp;amp;i.xlsx'
dbms=xlsx replace out=&amp;amp;reg_&amp;amp;typ_&amp;amp;i;
getnames=yes;
run;

data &amp;amp;reg_&amp;amp;typ;
set &amp;amp;reg_&amp;amp;typ_&amp;amp;i;
drop Date_Time;
if Date=' ' and Event=' ' then delete;
rename Country_Region=Region;
rename Surv_M_=Surv_M;
rename Surv_A_=Surv_A;
rename Std_Dev=SD;
rename Last_Rev_=Last_Rev;
run;
%end;
%mend impcol;
%impcol (EU,CB,1,2);&lt;/PRE&gt;&lt;P&gt;I get the following errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2137 %macro impcol (reg,typ,start,count);&lt;BR /&gt;2138 %do i=&amp;amp;start %to &amp;amp;count;&lt;BR /&gt;2139 proc import datafile='C:\Users\Deepan\OneDrive\Brock Studies\Fall 2018\Thesis\Data\WIP\Eco&lt;BR /&gt;2139! Data\Common\&amp;amp;reg_&amp;amp;typ_&amp;amp;i.xlsx'&lt;BR /&gt;2140 dbms=xlsx replace out=&amp;amp;reg_&amp;amp;typ_&amp;amp;i;&lt;BR /&gt;2141 getnames=yes;&lt;BR /&gt;2142 run;&lt;BR /&gt;2143&lt;BR /&gt;2144 data &amp;amp;reg_&amp;amp;typ;&lt;BR /&gt;2145 set &amp;amp;reg_&amp;amp;typ_&amp;amp;i;&lt;BR /&gt;2146 drop Date_Time;&lt;BR /&gt;2147 if Date=' ' and Event=' ' then delete;&lt;BR /&gt;2148 rename Country_Region=Region;&lt;BR /&gt;2149 rename Surv_M_=Surv_M;&lt;BR /&gt;2150 rename Surv_A_=Surv_A;&lt;BR /&gt;2151 rename Std_Dev=SD;&lt;BR /&gt;2152 rename Last_Rev_=Last_Rev;&lt;BR /&gt;2153 run;&lt;BR /&gt;2154 %end;&lt;BR /&gt;2155 %mend impcol;&lt;BR /&gt;2156 %impcol (EU,CB,1,2);&lt;BR /&gt;NOTE: Line generated by the invoked macro "IMPCOL".&lt;BR /&gt;1 proc import datafile='C:\Users\Deepan\OneDrive\Brock Studies\Fall 2018\Thesis\Data\WIP\Eco&lt;BR /&gt;1 ! Data\Common\&amp;amp;reg_&amp;amp;typ_&amp;amp;i.xlsx' dbms=xlsx replace out=&amp;amp;reg_&amp;amp;typ_&amp;amp;i; getnames=yes; run; data&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;WARNING: Apparent symbolic reference REG_ not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TYP_ not resolved.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: Apparent symbolic reference REG_ not resolved.&lt;BR /&gt;NOTE: Line generated by the invoked macro "IMPCOL".&lt;BR /&gt;1 &amp;amp;reg_&amp;amp;typ_&amp;amp;i; getnames=yes; run;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;ERROR 22-322: Expecting a name.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: Line generated by the invoked macro "IMPCOL".&lt;BR /&gt;1 data &amp;amp;reg_&amp;amp;typ; set&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;200&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;,&lt;BR /&gt;_DATA_, _LAST_, _NULL_.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;1 ! data &amp;amp;reg_&amp;amp;typ; set&lt;BR /&gt;1 ! &amp;amp;reg_&amp;amp;typ_&amp;amp;i; drop Date_Time; if Date=' ' and Event=' '&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;WARNING: Apparent symbolic reference REG_ not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TYP_ not resolved.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, CUROBS,&lt;BR /&gt;END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "IMPCOL".&lt;BR /&gt;1 &amp;amp;reg_&amp;amp;typ_&amp;amp;i; drop Date_Time; if Date=' ' and Event=' '&lt;/P&gt;&lt;P&gt;-&lt;BR /&gt;-&lt;/P&gt;&lt;P&gt;200&lt;BR /&gt;22&lt;/P&gt;&lt;P&gt;200&lt;BR /&gt;ERROR: File WORK.REG_.DATA does not exist.&lt;BR /&gt;ERROR: File WORK.TYP_1.DATA does not exist.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;,&lt;BR /&gt;CUROBS, END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_,&lt;BR /&gt;_NULL_.&lt;/P&gt;&lt;P&gt;WARNING: The variable Date_Time in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Country_Region in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Surv_M_ in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Surv_A_ in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Std_Dev in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Last_Rev_ in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.REG_CB may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 2 variables.&lt;BR /&gt;WARNING: Data set WORK.REG_CB was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.05 seconds&lt;BR /&gt;cpu time 0.04 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: Line generated by the invoked macro "IMPCOL".&lt;BR /&gt;4 proc import datafile='C:\Users\Deepan\OneDrive\Brock Studies\Fall 2018\Thesis\Data\WIP\Eco&lt;BR /&gt;4 ! Data\Common\&amp;amp;reg_&amp;amp;typ_&amp;amp;i.xlsx' dbms=xlsx replace out=&amp;amp;reg_&amp;amp;typ_&amp;amp;i; getnames=yes; run; data&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;WARNING: Apparent symbolic reference REG_ not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TYP_ not resolved.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: Apparent symbolic reference REG_ not resolved.&lt;BR /&gt;NOTE: Line generated by the invoked macro "IMPCOL".&lt;BR /&gt;4 &amp;amp;reg_&amp;amp;typ_&amp;amp;i; getnames=yes; run;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;ERROR 22-322: Expecting a name.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: Line generated by the invoked macro "IMPCOL".&lt;BR /&gt;4 data &amp;amp;reg_&amp;amp;typ; set&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;200&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;,&lt;BR /&gt;_DATA_, _LAST_, _NULL_.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;4 ! data &amp;amp;reg_&amp;amp;typ; set&lt;BR /&gt;4 ! &amp;amp;reg_&amp;amp;typ_&amp;amp;i; drop Date_Time; if Date=' ' and Event=' '&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;WARNING: Apparent symbolic reference REG_ not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TYP_ not resolved.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, CUROBS,&lt;BR /&gt;END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "IMPCOL".&lt;BR /&gt;4 &amp;amp;reg_&amp;amp;typ_&amp;amp;i; drop Date_Time; if Date=' ' and Event=' '&lt;/P&gt;&lt;P&gt;-&lt;BR /&gt;-&lt;/P&gt;&lt;P&gt;200&lt;BR /&gt;22&lt;/P&gt;&lt;P&gt;200&lt;BR /&gt;ERROR: File WORK.REG_.DATA does not exist.&lt;BR /&gt;ERROR: File WORK.TYP_2.DATA does not exist.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;,&lt;BR /&gt;CUROBS, END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_,&lt;BR /&gt;_NULL_.&lt;/P&gt;&lt;P&gt;WARNING: The variable Date_Time in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Country_Region in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Surv_M_ in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Surv_A_ in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Std_Dev in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;WARNING: The variable Last_Rev_ in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.REG_CB may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 2 variables.&lt;BR /&gt;WARNING: Data set WORK.REG_CB was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.04 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Oct 2018 07:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/What-s-wrong-with-this-SAS-macro-code/m-p/508083#M1597</guid>
      <dc:creator>d6k5d3</dc:creator>
      <dc:date>2018-10-28T07:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this SAS macro code?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/What-s-wrong-with-this-SAS-macro-code/m-p/508084#M1598</link>
      <description>&lt;P&gt;Make it a habit to always end macro variable references with a dot, and use double quotes for strings where macro variables need to be resolved:&lt;/P&gt;
&lt;PRE&gt;"C:\Users\...\&amp;amp;reg._&amp;amp;typ._&amp;amp;i..xlsx"&lt;/PRE&gt;
&lt;P&gt;Without the dot, the macro preprocessor tries to find macro variable reg_ instead of just reg. Note the double dot: one terminates the reference to &amp;amp;i, the other one stays in the string and goes into the filename.&lt;/P&gt;
&lt;P&gt;Do the same throughout your macro wherever you reference the macro variables.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Oct 2018 07:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/What-s-wrong-with-this-SAS-macro-code/m-p/508084#M1598</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-28T07:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this SAS macro code?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/What-s-wrong-with-this-SAS-macro-code/m-p/508086#M1599</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, thank you! I will never forget the pieces of advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Oct 2018 07:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/What-s-wrong-with-this-SAS-macro-code/m-p/508086#M1599</guid>
      <dc:creator>d6k5d3</dc:creator>
      <dc:date>2018-10-28T07:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with this SAS macro code?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/What-s-wrong-with-this-SAS-macro-code/m-p/508259#M1638</link>
      <description>&lt;P&gt;You can find this advice as Maxim #48 in &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 07:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/What-s-wrong-with-this-SAS-macro-code/m-p/508259#M1638</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-29T07:58:01Z</dc:date>
    </item>
  </channel>
</rss>

