<?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: Creating a macro variable using a macro value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460717#M117126</link>
    <description>&lt;P&gt;I apologize for the miscommunication.&amp;nbsp; I set these macros to global in an earlier section of code, so that was not the issue.&amp;nbsp; I was getting an error message from the %put statement "WARNING: Apparent symbolic reference IMPORT_CCBF_DD_ not resolved.&lt;BR /&gt;&amp;amp;import_CCBF_DD_CCBF_DD_err"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believed this to be a problem with the creation of the macro, but the issue was in the %put statement, solved by adding the second &amp;amp; (&lt;SPAN&gt;%put &amp;amp;&amp;amp;import_DD_&amp;amp;out_DD._err;) mentioned by Astounding.&amp;nbsp; In hindsight I should have set the macro variable to blank then run the code again.&amp;nbsp; It was my belief the value assigned to the macro was from an earlier attempt.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks for everyone's input.&amp;nbsp; It was very helpful.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 May 2018 14:49:16 GMT</pubDate>
    <dc:creator>Ryanb2</dc:creator>
    <dc:date>2018-05-08T14:49:16Z</dc:date>
    <item>
      <title>Creating a macro variable using a macro value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460582#M117080</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro import_DD(In_DD,Out_DD);
PROC IMPORT OUT= WORK.&amp;amp;Out_DD._raw 
            DATAFILE= "C:\Projects\Data Dictionary_with_variable_names.xlsx" DBMS=EXCEL REPLACE; RANGE="'&amp;amp;In_DD.$'"; 
			GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN;
%let import_DD_&amp;amp;Out_DD._err=&amp;amp;SYSERR;  
%put &amp;amp;import_DD_&amp;amp;Out_DD._err;
%mend import_DD;
%import_DD(DATA DICTIONARY,DD);
%import_DD(APPENDIX A1-CDPH State Codes,A1_DD);
%import_DD(APPENDIX A2- MARC (Country),A2_DD);
%import_DD(APPENDIX B-Country FIPS Codes,B_DD);
%import_DD(APPENDIX C_State FIPS Codes,C_DD);
%import_DD(APPENDIX D-Race Codes,D_DD);
%import_DD(APPENDIX G-County Codes,G_DD);
%import_DD(APPENDIX H-VS 10A,H_DD);
%import_DD(APPENDIX I-HOSPITAL CODES,I_DD);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The code above imports a data dictionary and appendices listed on different tabs in an Excel file.&amp;nbsp; I'd like to assign &amp;amp;SYSERR after each import to a new macro variable so I can track whether or not there were errors during import, but I'm struggling to find code that will allow me to use the macro variable assigned at the top of the macro to name the new macro used to capture error codes.&amp;nbsp; Any assistance is appreciated.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 21:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460582#M117080</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2018-05-07T21:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro variable using a macro value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460588#M117083</link>
      <description>&lt;P&gt;The assignment with %LET is fine, although the macro variable will be created in the local symbol table.&amp;nbsp; If you need it to be global so that it exists after the macro is over, add this statement before %LET:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%global import_DD_&amp;amp;Out_DD._err;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the %PUT statement to work, use a double-ampersand:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;&amp;amp;import_DD_&amp;amp;out_DD._err;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 22:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460588#M117083</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-07T22:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro variable using a macro value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460589#M117084</link>
      <description>&lt;P&gt;Maybe you should make the variable(s) global so you have access to them after the macro runs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global import_DD_&amp;amp;Out_DD._err;
%let import_DD_&amp;amp;Out_DD._err = &amp;amp;syserr;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 May 2018 22:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460589#M117084</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-05-07T22:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro variable using a macro value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460590#M117085</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/46197"&gt;@Ryanb2&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The code above imports a data dictionary and appendices listed on different tabs in an Excel file.&amp;nbsp; I'd like to assign &amp;amp;SYSERR after each import to a new macro variable so I can track whether or not there were errors during import, &lt;FONT color="#0000ff" size="5"&gt;but I'm struggling to find code &lt;/FONT&gt;that will allow me to use the macro variable assigned at the top of the macro to name the new macro used to capture error codes.&amp;nbsp; Any assistance is appreciated.&amp;nbsp; Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please describe exactly how you are struggling.&lt;/P&gt;
&lt;P&gt;Currently the macro variable you are creating is only going to be local to that macro call. If you want to have it available after the macro terminates you will need a %global &amp;lt;your new macro variable here&amp;gt;; before assigning a value.&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 22:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460590#M117085</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-07T22:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro variable using a macro value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460597#M117088</link>
      <description>&lt;P&gt;Do you mean something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global run_no;
%let run_no = 0;
%macro import_DD(In_DD,Out_DD);
   %let run_no = %eval(&amp;amp;run_no + 1);
   %let import_rc = r&amp;amp;run_no._err;
    PROC IMPORT OUT= WORK.&amp;amp;Out_DD._raw 
          DATAFILE= "C:\Projects\Data Dictionary_with_variable_names.xlsx" 
         DBMS=EXCEL REPLACE; RANGE="'&amp;amp;In_DD.$'"; 
	GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; 
        SCANTIME=YES; 
   RUN;
   %let &amp;amp;import_rc = &amp;amp;syserr;
   %put &amp;amp;import_rc is &amp;amp;&amp;amp;import_rc;
  /********
    %let import_DD_&amp;amp;Out_DD._err=&amp;amp;SYSERR;  
    %put &amp;amp;import_DD_&amp;amp;Out_DD._err;
 *********/
%mend import_DD;
%import_DD(DATA DICTIONARY,DD);
%import_DD(APPENDIX A1-CDPH State Codes,A1_DD);&lt;BR /&gt;... etc. ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will get in log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; r1_err is .....&amp;nbsp; &amp;nbsp; /* 1st macro run syserr */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; r2_err is ....&amp;nbsp; &amp;nbsp; &amp;nbsp;/* 2nd macro run syserr */&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 23:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460597#M117088</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-05-07T23:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a macro variable using a macro value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460717#M117126</link>
      <description>&lt;P&gt;I apologize for the miscommunication.&amp;nbsp; I set these macros to global in an earlier section of code, so that was not the issue.&amp;nbsp; I was getting an error message from the %put statement "WARNING: Apparent symbolic reference IMPORT_CCBF_DD_ not resolved.&lt;BR /&gt;&amp;amp;import_CCBF_DD_CCBF_DD_err"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believed this to be a problem with the creation of the macro, but the issue was in the %put statement, solved by adding the second &amp;amp; (&lt;SPAN&gt;%put &amp;amp;&amp;amp;import_DD_&amp;amp;out_DD._err;) mentioned by Astounding.&amp;nbsp; In hindsight I should have set the macro variable to blank then run the code again.&amp;nbsp; It was my belief the value assigned to the macro was from an earlier attempt.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks for everyone's input.&amp;nbsp; It was very helpful.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 14:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-macro-variable-using-a-macro-value/m-p/460717#M117126</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2018-05-08T14:49:16Z</dc:date>
    </item>
  </channel>
</rss>

