<?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: call a macro through datatep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442286#M110645</link>
    <description>&lt;P&gt;"Dear doc, I won't tell you where it hurts, but could you give me a diagnosis?"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just mask out the company-specific names and values, what's important is the program structure inside the macro (which statements etc)&lt;/P&gt;</description>
    <pubDate>Mon, 05 Mar 2018 10:00:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-03-05T10:00:34Z</dc:date>
    <item>
      <title>call a macro through datatep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442278#M110639</link>
      <description>&lt;P&gt;data new;&lt;BR /&gt;input x;&lt;BR /&gt;datalines;&lt;BR /&gt;t1&lt;BR /&gt;T2&lt;BR /&gt;T3&lt;BR /&gt;T4&lt;BR /&gt;T5&lt;BR /&gt;T6&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a macro called find .In this macro if I have pass T1 it gives me full table name&lt;/P&gt;&lt;P&gt;for ex&lt;/P&gt;&lt;P&gt;%find(t1)&lt;/P&gt;&lt;P&gt;output will be a dataset called table_desc with one variable table_name have value cust_dept for input t&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new macro called great&lt;/P&gt;&lt;P&gt;%macro great&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select count(distinct x) into :total from new&lt;/P&gt;&lt;P&gt;order by x;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select distinct x into :name1- :name&amp;amp;total.from new&lt;/P&gt;&lt;P&gt;order by x;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;data xyz;&lt;BR /&gt;set new;&lt;BR /&gt;%do i=1 to &amp;amp;total.;&lt;BR /&gt;%find(&amp;amp;&amp;amp;name&amp;amp;i.);&lt;BR /&gt;tabel=t1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%great&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my final output of xyz&lt;/P&gt;&lt;P&gt;tabel tabel_name&lt;BR /&gt;t1 cust_dept&lt;BR /&gt;t2 dept_accunt&lt;BR /&gt;t3 accunt_customer&lt;BR /&gt;t4 account_new&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please help me how can I acheive this&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 09:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442278#M110639</guid>
      <dc:creator>Rohit12</dc:creator>
      <dc:date>2018-03-05T09:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: call a macro through datatep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442281#M110641</link>
      <description>&lt;P&gt;Post example have data (for each dataset) in a datastep so we have something to work with, and what the output should look like.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems like your problem is a very simple one that needs none of that code simply:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  select  memname,memlabel
  from    sashelp.vtable where memname in (select x from new);
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Mar 2018 09:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442281#M110641</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-05T09:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: call a macro through datatep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442282#M110642</link>
      <description>&lt;P&gt;Please post the code of macro %find.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 09:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442282#M110642</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-05T09:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: call a macro through datatep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442285#M110644</link>
      <description>I cannot post the code of macro find as it is company specific macro</description>
      <pubDate>Mon, 05 Mar 2018 09:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442285#M110644</guid>
      <dc:creator>Rohit12</dc:creator>
      <dc:date>2018-03-05T09:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: call a macro through datatep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442286#M110645</link>
      <description>&lt;P&gt;"Dear doc, I won't tell you where it hurts, but could you give me a diagnosis?"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just mask out the company-specific names and values, what's important is the program structure inside the macro (which statements etc)&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 10:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442286#M110645</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-05T10:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: call a macro through datatep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442304#M110650</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120326"&gt;@Rohit12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can't post something because it's company specific/confidential then try to dummy up some representative code/data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To use a SAS data step and call a macro multiple times, passing in for each iteration of the data step another parameter value:&lt;/P&gt;
&lt;P&gt;That's what CALL EXECUTE() is for.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1blnvlvciwgs9n0zcilud6d6ei9.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1blnvlvciwgs9n0zcilud6d6ei9.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here a code sample&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro sample(param=);
  data _null_;
    put "Parameter is: &amp;amp;Param";
    stop;
  run;
%mend;


data paramList;
  var='abcd xyz'; output;
  var='xy dd'; output;
run;

data _null_;
  set paramList;
  call execute('%sample(param='||var||');');
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Mar 2018 11:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442304#M110650</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-03-05T11:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: call a macro through datatep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442319#M110654</link>
      <description>&lt;P&gt;I have created one example macro as you can not share the macro code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suggestion: Please make sure the table descriptions get appended not replaced on repetitive call of the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro find(tabname=);
	%put &amp;amp;tabname.;
%mend find;

data tablist;
input tables:$20.;
cards;
account
people
list
transaction
amortization
service
;
run;

proc sql noprint;
select distinct '%find(tabname='||strip(tables)||')' into :runmacro separated by ';' from tablist;
quit;

&amp;amp;runmacro.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Mar 2018 12:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442319#M110654</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-03-05T12:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: call a macro through datatep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442399#M110679</link>
      <description>&lt;P&gt;If your macro %find involves any procedures or calls a data step such as&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;any other code&amp;gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the data step "calling" find will quit as soon as it finds proc or data statement as that is a boundary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;data junk;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; x=3;&lt;/P&gt;
&lt;P&gt;proc print data=sashelp.class;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the "proc print" tells SAS that the data step Junk is finished.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 15:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-a-macro-through-datatep/m-p/442399#M110679</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-05T15:45:18Z</dc:date>
    </item>
  </channel>
</rss>

