<?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 referencing a variable from another dataset in a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/referencing-a-variable-from-another-dataset-in-a-macro/m-p/470197#M120356</link>
    <description>&lt;P&gt;I have a macro that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro csv(chart);&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;where chart_code = "&amp;amp;chart.";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend csv(chart);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro works when I input a value into chart. However I want to run this macro through the chart_code variable from a data set that looks like this:&lt;/P&gt;&lt;P&gt;Chart_code&lt;/P&gt;&lt;P&gt;test13&lt;BR /&gt;test3&lt;BR /&gt;test4&lt;BR /&gt;test6&lt;BR /&gt;test9&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i.e run the macro through test13, test 3 and so on.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jun 2018 05:54:17 GMT</pubDate>
    <dc:creator>BenBrady</dc:creator>
    <dc:date>2018-06-14T05:54:17Z</dc:date>
    <item>
      <title>referencing a variable from another dataset in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/referencing-a-variable-from-another-dataset-in-a-macro/m-p/470197#M120356</link>
      <description>&lt;P&gt;I have a macro that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro csv(chart);&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;where chart_code = "&amp;amp;chart.";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend csv(chart);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro works when I input a value into chart. However I want to run this macro through the chart_code variable from a data set that looks like this:&lt;/P&gt;&lt;P&gt;Chart_code&lt;/P&gt;&lt;P&gt;test13&lt;BR /&gt;test3&lt;BR /&gt;test4&lt;BR /&gt;test6&lt;BR /&gt;test9&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i.e run the macro through test13, test 3 and so on.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 05:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/referencing-a-variable-from-another-dataset-in-a-macro/m-p/470197#M120356</guid>
      <dc:creator>BenBrady</dc:creator>
      <dc:date>2018-06-14T05:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: referencing a variable from another dataset in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/referencing-a-variable-from-another-dataset-in-a-macro/m-p/470200#M120358</link>
      <description>&lt;P&gt;Use call execute():&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set control_dataset;
call execute('%csv(' !! strip(chart_code) !! ');');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the use of single quotes to prevent premature resolution of the macro. If the macro contains macro statements, use %nrstr( to mask the macro trigger so that the execution of the macro is delayed until the contained data/proc step code can execute.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 06:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/referencing-a-variable-from-another-dataset-in-a-macro/m-p/470200#M120358</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-14T06:05:54Z</dc:date>
    </item>
  </channel>
</rss>

