<?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: How to get the value of my macro variable in this string. The string has both single and double in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772156#M245152</link>
    <description>&lt;P&gt;Do you mean I need to add a new column (containing the environment) to my input table? That is of course an option. Since this is a work-table I could live with that.&amp;nbsp; An option I will try. I still think the other option with the double quotation marks is the best ... when we can make it work of course.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Oct 2021 13:33:53 GMT</pubDate>
    <dc:creator>Longimanus</dc:creator>
    <dc:date>2021-10-05T13:33:53Z</dc:date>
    <item>
      <title>How to get the value of my macro variable in this string. The string has both single and double 's</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772138#M245143</link>
      <description>&lt;P&gt;I hope somebody can help me with this:&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":crossed_fingers:"&gt;🤞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Intro:&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I have a table, &lt;EM&gt;&lt;STRONG&gt;x_selected_reports&lt;/STRONG&gt;&lt;/EM&gt;,&amp;nbsp; that during a process will contain program names to be executed. Each row will contain a program name in the column&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;x_rc_rprt_nm&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/LI&gt;
&lt;LI&gt;We have three environments/servers: development (Lev1), test (Lev2) and the production environment (Lev3)&lt;/LI&gt;
&lt;LI&gt;The path of where this table is found is the problem. If I hard code the environamnt, e.g.: /Lev1/ it all works fine in the call execute command. I like to this to change depending on where it's run. I cannot complete the puzzle how to fix this due to the quotations.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;&lt;U&gt;This works:&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;data _null_; &lt;BR /&gt;set x_selected_reports;&lt;BR /&gt;Execcode = '&lt;/P&gt;
&lt;P&gt;%include&amp;nbsp; "/opt/app/sas94/config/&lt;FONT face="arial black,avant garde"&gt;&lt;STRONG&gt;Lev1&lt;/STRONG&gt;&lt;/FONT&gt;/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'||strip(x_rc_rprt_nm)||'.sas";&lt;/P&gt;
&lt;P&gt;'; &lt;BR /&gt;call execute(execcode); &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;FONT face="arial black,avant garde"&gt;This does not work&lt;/FONT&gt;&lt;/U&gt; &lt;EM&gt;&lt;FONT face="comic sans ms,sans-serif"&gt;(of course it doesn't but you can see what I want to do)&lt;/FONT&gt;&lt;/EM&gt;:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let Levx=%sysget(LEVX);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_; &lt;BR /&gt;set x_selected_reports;&lt;BR /&gt;Execcode = '&lt;/P&gt;
&lt;P&gt;%include&amp;nbsp; "/opt/app/sas94/config/&lt;FONT face="arial black,avant garde"&gt;&lt;STRONG&gt;&amp;amp;Levx.&lt;/STRONG&gt;&lt;/FONT&gt;/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'||strip(x_rc_rprt_nm)||'.sas";&lt;/P&gt;
&lt;P&gt;'; &lt;BR /&gt;call execute(execcode); &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In other words: HOW do I get &lt;STRONG&gt;Execcode&lt;/STRONG&gt; to be:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;'%include&amp;nbsp; "/opt/app/sas94/config/&lt;STRONG&gt;Lev1&lt;/STRONG&gt;/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'||strip(x_rc_rprt_nm)||'.sas";'&lt;/LI&gt;
&lt;LI&gt;'%include&amp;nbsp; "/opt/app/sas94/config/&lt;STRONG&gt;Lev2&lt;/STRONG&gt;/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'||strip(x_rc_rprt_nm)||'.sas";'&lt;/LI&gt;
&lt;LI&gt;'%include&amp;nbsp; "/opt/app/sas94/config/&lt;STRONG&gt;Lev3&lt;/STRONG&gt;/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'||strip(x_rc_rprt_nm)||'.sas";'&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;... depending on the environment.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't decoded the issue with ''s and "'s in a text sting that again has to be in quotes, etc. etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope somebody likes to give it a try.&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers!&lt;/P&gt;
&lt;P&gt;Menno (Copenhagen - DK)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 12:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772138#M245143</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2021-10-05T12:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the value of my macro variable in this string. The string has both single and double</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772139#M245144</link>
      <description>&lt;P&gt;Macro variables don't resolve within single quotes.&amp;nbsp; You would need to swap the single vs. double quotes, from this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Execcode = '

%include  "/opt/app/sas94/config/&amp;amp;Levx./SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'||strip(x_rc_rprt_nm)||'.sas";

';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to this so that double quotes are outermost:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Execcode = "

%include  '/opt/app/sas94/config/&amp;amp;Levx./SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/"||strip(x_rc_rprt_nm)||".sas';

";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Oct 2021 12:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772139#M245144</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-10-05T12:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the value of my macro variable in this string. The string has both single and double</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772140#M245145</link>
      <description>Omg ... that easy? I will give that a try! Thanx !!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 05 Oct 2021 12:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772140#M245145</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2021-10-05T12:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the value of my macro variable in this string. The string has both single and double</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772143#M245146</link>
      <description>&lt;P&gt;Why not to add variable with env. name, e.g. x_Level and do it like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Execcode = '
%include  "/opt/app/sas94/config/' !! strip(x_Level) !! '/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/' || strip(x_rc_rprt_nm) || '.sas";
';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 12:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772143#M245146</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-10-05T12:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the value of my macro variable in this string. The string has both single and double</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772151#M245148</link>
      <description>&lt;P&gt;I can see that the macro variable is "translated" but now there is another issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Let Levx=%sysget(LEVX);&lt;BR /&gt;%put &amp;amp;Levx.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;This runs perfect:&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;data _null_; &lt;BR /&gt;set x_selected_reports;&lt;BR /&gt;Execcode = &lt;FONT face="arial black,avant garde"&gt;'&lt;/FONT&gt;%include "/opt/app/sas94/config/Lev1/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'||strip(x_rc_rprt_nm)||'.sas";&lt;FONT face="arial black,avant garde"&gt;'&lt;/FONT&gt;;&lt;BR /&gt;call execute(execcode); &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Your suggestion does not - although my macro variable is resolved &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;. Something else in the syntax is not working now:&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;data _null_; &lt;BR /&gt;set x_selected_reports;&lt;BR /&gt;Execcode = &lt;FONT face="arial black,avant garde"&gt;"&lt;/FONT&gt;%include "/opt/app/sas94/config/&amp;amp;Levx./SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'||strip(x_rc_rprt_nm)||'.sas";&lt;FONT face="arial black,avant garde"&gt;"&lt;/FONT&gt;; &lt;BR /&gt;call execute(execcode); &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;LOG of the data step that run as it should:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;NOTE: Remote submit to LEV1 commencing.&lt;BR /&gt;355 data _null_;&lt;BR /&gt;356 set x_selected_reports;&lt;BR /&gt;357 Execcode = '%include&lt;BR /&gt;357! "/opt/app/sas94/config/Lev1/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'||strip(x_rc_&lt;BR /&gt;357! rprt_nm)||'.sas";';&lt;BR /&gt;358 call execute(execcode);&lt;BR /&gt;359 run;&lt;/P&gt;
&lt;P&gt;NOTE: There were 2 observations read from the data set WORK.X_SELECTED_REPORTS.&lt;BR /&gt;NOTE: DATA statement 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;&lt;BR /&gt;NOTE: CALL EXECUTE generated line.&lt;BR /&gt;1 + %include&lt;BR /&gt;"/opt/app/sas94/config/Lev1/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/Test_program_1.sas"&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;NOTE: The data set ANALYS.TEST_OUTPUT_1 has 1 observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement 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;&lt;BR /&gt;2 + %include&lt;BR /&gt;"/opt/app/sas94/config/Lev1/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/Test_program_2.sas"&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;NOTE: The data set ANALYS.TEST_OUTPUT_2 has 1 observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement 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;&lt;BR /&gt;NOTE: Remote submit to LEV1 complete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;LOG of the data step did not run:&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;378 call execute(execcode);&lt;BR /&gt;379 run;&lt;/P&gt;
&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;377:16 377:105 377:134&lt;BR /&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;378:18&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NOTE: Remote submit to LEV1 complete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt; If somebody can crack this one it would he highly appreciated. In the meantime I will puzzle a little myself.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers!&lt;/P&gt;
&lt;P&gt;Menno&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 13:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772151#M245148</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2021-10-05T13:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the value of my macro variable in this string. The string has both single and double</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772152#M245149</link>
      <description>I will give this a try too. Thank you!</description>
      <pubDate>Tue, 05 Oct 2021 13:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772152#M245149</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2021-10-05T13:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the value of my macro variable in this string. The string has both single and double</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772156#M245152</link>
      <description>&lt;P&gt;Do you mean I need to add a new column (containing the environment) to my input table? That is of course an option. Since this is a work-table I could live with that.&amp;nbsp; An option I will try. I still think the other option with the double quotation marks is the best ... when we can make it work of course.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 13:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772156#M245152</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2021-10-05T13:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the value of my macro variable in this string. The string has both single and double</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772160#M245154</link>
      <description>&lt;P&gt;You can use SAS functions to simplify your code.&lt;/P&gt;
&lt;P&gt;Use the CATS() or CATX() function to build the strings. Use the SYSGET() function to retrieve your environment variable. Use the QUOTE() function to enclose the generated filename in quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set x_selected_reports;
  call execute(catx(' ','%include'
      ,quote(cats('/opt/app/sas94/config/'
                 ,sysget('LEVX')
                 ,'/SASApp/SASEnvironment/SASCode/Adhoc/Risk_Reports/'
                 ,x_rc_rprt_nm
                 ,'.sas'
       ))
  ));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Oct 2021 13:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772160#M245154</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-05T13:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the value of my macro variable in this string. The string has both single and double</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772162#M245155</link>
      <description>&lt;P&gt;It looks a lot like you are placing your SAS project code into the filesystem you have used to install the SAS software.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably will want to keep those two things separate. They are really separate things.&amp;nbsp; They have separate sources, space needs, update cycles, access permission needs, etc.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 13:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-value-of-my-macro-variable-in-this-string-The/m-p/772162#M245155</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-05T13:51:07Z</dc:date>
    </item>
  </channel>
</rss>

