<?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: Using a Macro variable in the VAR statement with PROC PRINT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491490#M128905</link>
    <description>&lt;P&gt;&lt;EM&gt;You could create NEW dataset and print that.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or a view:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;title&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;Any Free Text &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; to_print/view=to_print&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  _title_&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"&amp;amp;title"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; sashelp&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;class&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;obs&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

title1 &lt;SPAN class="token string"&gt;"I added the column _TITLE_ with the value &amp;amp;title"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;print&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;to_print&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 31 Aug 2018 02:05:27 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-08-31T02:05:27Z</dc:date>
    <item>
      <title>Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491017#M128652</link>
      <description>&lt;P&gt;Suppose I have the following (as a case example):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let title = MyTitle&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and a data set called BOOKS with some variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=books ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var &amp;amp;title author year publisher ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; title1 "Macro var resolves&amp;nbsp; &amp;amp;title" ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro var will resolve correctly in the Title1 statement.&amp;nbsp; However, the use of &amp;amp;title in the VAR statement causes an error.&lt;/P&gt;
&lt;P&gt;I tried put(&amp;amp;title) or quotes around &amp;amp;title in the VAR statement , etc. but no work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the VAR references an &lt;EM&gt;existing macro variable &lt;/EM&gt;it WILL work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let mvar1 = MyTitle ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var &amp;amp;mvar1 ;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;will work fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I could use&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;datastep;_&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; title = SYMGET(&amp;amp;title) ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to pass it to the dataset but I would like to see if there is a more direct way with the VAR statement itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any discussion of pros/cons appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 22:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491017#M128652</guid>
      <dc:creator>Kow</dc:creator>
      <dc:date>2018-08-29T22:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491018#M128653</link>
      <description>&lt;P&gt;This makes little sense that you are trying to tell SAS to use a variable named "MyTitle", there is no such thing as a variable named "MyTitle". Why? Becuase variable names do not have quotes or doublequotes in them. On the other hand, if you use &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let title=mytitle;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;without any quotes, and you have such a variable in the data set, then it should work.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 22:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491018#M128653</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-08-29T22:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491019#M128654</link>
      <description>&lt;P&gt;is this part of your code correct in the first place?&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;amp;title = "My Title " ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or one should assume you have&amp;nbsp; an existing macro var by the name title?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 22:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491019#M128654</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-29T22:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491020#M128655</link>
      <description>&lt;P&gt;Yes, I note the syntax error and have corrected it.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 22:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491020#M128655</guid>
      <dc:creator>Kow</dc:creator>
      <dc:date>2018-08-29T22:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491021#M128656</link>
      <description>&lt;P&gt;well in that case, like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;pointed out, it should work fine. If not, please post us the log report. Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 22:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491021#M128656</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-29T22:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491134#M128727</link>
      <description>&lt;DIV class="sasSource"&gt;Here's a log. Looking at it it seems obvious that the call to &amp;amp;var1 will resolve to "Mytitle" and fail in the print var statement since there is no variable called MyTitle.&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;This problem occurred to me when I was thinking about how to get the value of a macro variable into the PROC PRINT. Typically, I just reference the value in a TITLE statement and that often covers it. But what if I want the value directly in the PROC PRINT itself? For example,&amp;nbsp; output to a PDF ?&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;You could use :&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;STRONG&gt;Data ;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataStepTitle&amp;nbsp; =symget('Var1' );&lt;/STRONG&gt;&amp;nbsp; **syntax is no ampersand and in quotes**;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;and then&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc print ;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR DataStepTitle ;&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; should then print the value MyTitle as wanted.&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;but I was looking and wondering if there is an alternate way, something along the lines of&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR "&amp;amp;title1" &amp;nbsp;&amp;nbsp; --&amp;nbsp;&lt;/STRONG&gt;which doesn't work.&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;73&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;74 %let var1 = Mytitle ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;75&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;76 data books ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;77 author = "KOWHEAD" ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;78 publisher = "Cow Books" ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;79 date = 2018 ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;80&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;81&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote1_1535616111987" class="sasNote"&gt;NOTE: The data set WORK.BOOKS has 1 observations and 3 variables.&lt;/DIV&gt;
&lt;DIV id="sasLogNote2_1535616111987" class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.00 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.00 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;82 proc print ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;83 var &amp;amp;var1 author publisher date ;&lt;/DIV&gt;
&lt;DIV id="sasLogError1_1535616111987" class="sasError"&gt;ERROR: Variable MYTITLE not found.&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;84 title "Case example: var1 is &amp;amp;var1" ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;85&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;86 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;99&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;PRE id="pre_sasLog_2" class="sasLog" style="background-color: transparent; -webkit-user-select: text; -webkit-user-modify: read-only; -webkit-touch-callout: default; border-top-width: 0px; border-bottom-width: 0px;"&gt;&amp;nbsp;&lt;/PRE&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;</description>
      <pubDate>Thu, 30 Aug 2018 08:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491134#M128727</guid>
      <dc:creator>Kow</dc:creator>
      <dc:date>2018-08-30T08:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491188#M128754</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;But what if I want the value directly in the PROC PRINT itself? For example,&amp;nbsp; output to a PDF ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Do you mean you want the variable to have a LABEL that is the value of the macro variable? Because so far your example indicates that the variable name (not the label) is specified by the macro variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please clarify this.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&amp;nbsp;VAR "&amp;amp;title1" &amp;nbsp;&amp;nbsp; --&amp;nbsp;&lt;/STRONG&gt;which doesn't work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes, because in the VAR statement, you can't use single quotes or double quotes. You can only use variable names (not labels) with no quotes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you show us working code for a single case that does what you want WITHOUT macros? If so, then it should be very easy to convert the working code WITHOUT macros to working code WITH macros ... but you have to do the first step of creating working code WITHOUT macros. You can't skip this step.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 12:12:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491188#M128754</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-08-30T12:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491480#M128900</link>
      <description>&lt;P&gt;Well, I have the solution by using SYMGET and it works fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a working example of what I am wondering :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;73&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;74 %let PassTitle = MyNewTitle ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;75&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;76 data books ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;77 author = "KOWHEAD" ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;78 publisher = "Cow Books" ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;79 date = 2018 ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;80 D_PassTitle = symget('PassTitle') ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; **solution passing macro value to data variable works fine**;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;81&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;82&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote1_1535674572858" class="sasNote"&gt;NOTE: The data set WORK.BOOKS has 1 observations and 4 variables.&lt;/DIV&gt;
&lt;DIV id="sasLogNote2_1535674572858" class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.00 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.00 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;83 proc print ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;84&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var D_PassTitle author publisher date ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;85&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; title "Case example: PassTitle is &amp;amp;PassTitle" ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;86&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;87 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;100&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;PRE class="sasLog" style="background-color: transparent; -webkit-user-select: text; -webkit-user-modify: read-only; -webkit-touch-callout: default; border-top-width: 0px; border-bottom-width: 0px;"&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;DIV id="IDX" class="systitleandfootercontainer" style="border-spacing: 1px;"&gt;
&lt;P&gt;&lt;SPAN class="c systemtitle"&gt;Output is produced correctly:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="c systemtitle"&gt;Case example: PassTitle is MyNewTitle&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&amp;lt;&amp;lt;resolves correctly in title ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;ARTICLE&gt;
&lt;TABLE class="table" style="border-spacing: 0;"&gt;&lt;CAPTION&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;D_PassTitle&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;author&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;publisher&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;date&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="data"&gt;MyNewTitle&lt;/TD&gt;
&lt;TD class="data"&gt;KOWHEAD&lt;/TD&gt;
&lt;TD class="data"&gt;Cow Books&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&amp;nbsp; &amp;lt;&amp;lt;&amp;lt;&amp;lt;The data Passed Macro Variable is now in the output &lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;PRE id="pre_sasLog_2" class="sasLog" style="background-color: transparent; -webkit-user-select: text; -webkit-user-modify: read-only; -webkit-touch-callout: default; border-top-width: 0px; border-bottom-width: 0px;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The question is there a simpler/alternate way to directly reference the macro variable in the VAR statement and have it resolve correctly without the need for the SYMGET.&amp;nbsp; For example, suppose the dataset was locked and I could not change it&amp;nbsp; I need to process thru some macro loop and have the macro value printed row by row alongside the data listing.&amp;nbsp; An intermediate data step would work but I was wondering if there might be some other syntax I could use that would allow this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i.e&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR&amp;nbsp;&amp;nbsp; &amp;amp;PassTitle&amp;nbsp;&amp;nbsp; Author pub date&amp;nbsp; ( in some syntactical form that resolves it correctly)&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 00:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491480#M128900</guid>
      <dc:creator>Kow</dc:creator>
      <dc:date>2018-08-31T00:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491486#M128903</link>
      <description>&lt;P&gt;You cannot add a variable to your data set without changing your data set.&lt;/P&gt;
&lt;P&gt;You could create NEW dataset and print that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let title=Any Free Text ;
data to_print;
  _title_="&amp;amp;title";
  set sashelp.class (obs=4);
run;

title1 "I added the column _TITLE_ with the value &amp;amp;title";
proc print data=to_print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;I added the column _TITLE_ with the value Any Free Text  

Obs       _title_        Name      Sex    Age    Height    Weight

 1     Any Free Text    Alfred      M      14     69.0      112.5
 2     Any Free Text    Alice       F      13     56.5       84.0
 3     Any Free Text    Barbara     F      13     65.3       98.0
 4     Any Free Text    Carol       F      14     62.8      102.5&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Aug 2018 01:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491486#M128903</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-31T01:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491489#M128904</link>
      <description>&lt;P&gt;The VAR statement can only take variable names as parameters.&lt;/P&gt;
&lt;P&gt;but SQL can print anything: [edited: sorry about the typo]&lt;/P&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
  title "Case example: var1 is &amp;amp;var1" ;
&amp;nbsp; select "&amp;amp;var1", author, publisher, date from TABLE;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 31 Aug 2018 06:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491489#M128904</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-31T06:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491490#M128905</link>
      <description>&lt;P&gt;&lt;EM&gt;You could create NEW dataset and print that.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or a view:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;title&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;Any Free Text &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; to_print/view=to_print&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  _title_&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"&amp;amp;title"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; sashelp&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;class&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;obs&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

title1 &lt;SPAN class="token string"&gt;"I added the column _TITLE_ with the value &amp;amp;title"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;print&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;to_print&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 02:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491490#M128905</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-31T02:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Macro variable in the VAR statement with PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491528#M128921</link>
      <description>&lt;P&gt;The SQL trick is a good one! I was unaware that SQL statements could be used in SAS code like this, that opens up a lot of ideas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this one wins the prize, using an intermediate data step will obviously work as well. If I needed a solution that's what I would probably wind up using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SQL solution is the kind of thing I was looking for and caps the learning experience for this question. Thanks to all contributors.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 06:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Macro-variable-in-the-VAR-statement-with-PROC-PRINT/m-p/491528#M128921</guid>
      <dc:creator>Kow</dc:creator>
      <dc:date>2018-08-31T06:37:05Z</dc:date>
    </item>
  </channel>
</rss>

