<?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 use Proc Content values into a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-Proc-Content-values-into-a-macro/m-p/642931#M191857</link>
    <description>&lt;P&gt;The easiest way is to skip the macro variable(s) and call the macro directly from the dataset that has the names already.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data outty;
  no+1;
  set contents ;
  where name=:'_' ;
  call execute(cats('%nrstr(%val)(no=',no,',aval=',name,')'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 25 Apr 2020 18:49:09 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-04-25T18:49:09Z</dc:date>
    <item>
      <title>how to use Proc Content values into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-Proc-Content-values-into-a-macro/m-p/642927#M191856</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an excel spread sheet that adds new column every week.&amp;nbsp; I want to create an efficient program where I don't need to manually add new columns every week&amp;nbsp; into the program, but rather hit the "run" button.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I had in mind. Let me know if it possible to execute these steps:&lt;/P&gt;&lt;P&gt;1. use Proc Contents to collect the variable names&lt;/P&gt;&lt;P&gt;2. use callsymput to create a macro of these variable names&lt;/P&gt;&lt;P&gt;3. create a local macro and calling these parameters with the callsymput values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example:&lt;/P&gt;&lt;P&gt;Proc contents (only want 'NAME' =: '_').&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HitmonTran_1-1587838819474.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38706i7B68A6D7B06A9293/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HitmonTran_1-1587838819474.png" alt="HitmonTran_1-1587838819474.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=instagram out=contents; run;

data outty;
set contents (where=(name=:'_'));
run;&lt;BR /&gt;
data _null_;
	set outty;
	call symput('u'||strip(put(varnum,best.)), strip(name));
run;
%put &amp;amp;u1 &amp;amp;u2 &amp;amp;u3 &amp;amp;u4 &amp;amp;u5 &amp;amp;u6 &amp;amp;u7;    /**how would i make this efficient without adding each week***/


%macro val (no=,aval=);
data one&amp;amp;no.;
	set instagram;
	col="&amp;amp;aval";
	values=&amp;amp;aval;
	output;
	keep col values;
run;
%mend val;

%val (no=1,aval=_brand_a);  /***how would i use the callsymput here without adding new macro calls every week**/
%val (no=2,aval=_brand_b);
%val (no=3,aval=_brand_c);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;THank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 18:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-Proc-Content-values-into-a-macro/m-p/642927#M191856</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2020-04-25T18:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to use Proc Content values into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-Proc-Content-values-into-a-macro/m-p/642931#M191857</link>
      <description>&lt;P&gt;The easiest way is to skip the macro variable(s) and call the macro directly from the dataset that has the names already.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data outty;
  no+1;
  set contents ;
  where name=:'_' ;
  call execute(cats('%nrstr(%val)(no=',no,',aval=',name,')'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Apr 2020 18:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-Proc-Content-values-into-a-macro/m-p/642931#M191857</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-25T18:49:09Z</dc:date>
    </item>
  </channel>
</rss>

