<?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 the content of a variable for a Macro Call in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524304#M142570</link>
    <description>&lt;P&gt;Message #4 updated to include code.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jan 2019 15:56:32 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-01-03T15:56:32Z</dc:date>
    <item>
      <title>Using the content of a variable for a Macro Call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524284#M142555</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i wrote this small Macro . It compares two Datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;at the Point&amp;nbsp;&lt;SPAN&gt;%comp(XXX,PatientOID);&lt;/SPAN&gt;&amp;nbsp; i will use for the call of the Dataset names the content of a variable, line by line, instead off.&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are many datasets to compare and i wrote the Dataset names with DIRLIST into a variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you will understand me... THANKS A LOT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro comp(ds=,id=); 

proc sort data=p3465_n.&amp;amp;ds out=&amp;amp;ds._new;
     by &amp;amp;id; 
run;
proc sort data = p3465_o.param_&amp;amp;ds out=&amp;amp;ds;
     by &amp;amp;id;
run;

title "---- Compare proc contents of &amp;amp;ds  -----";
proc compare base=&amp;amp;ds._new comp=&amp;amp;ds listall maxprint=(3200,3200);
 id &amp;amp;id;
 *where visitnum&amp;lt;50;
run;
title;

%mend;



%comp(XXX,PatientOID);&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jan 2019 15:15:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524284#M142555</guid>
      <dc:creator>struppi1979</dc:creator>
      <dc:date>2019-01-03T15:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using the content of a variable for a Macro Call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524299#M142565</link>
      <description>&lt;P&gt;And what is the question?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2019 15:41:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524299#M142565</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-03T15:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using the content of a variable for a Macro Call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524301#M142567</link>
      <description>&lt;P&gt;… ok:&lt;/P&gt;&lt;P&gt;this is the Macro Call.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%comp(&lt;STRONG&gt;XXX&lt;/STRONG&gt;,PatientOID);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and in the Variable 'both'&amp;nbsp; in the Field varname there stand the variable names.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i need a help to paste the variable names automatically to&lt;STRONG&gt; XXX.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2019 15:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524301#M142567</guid>
      <dc:creator>struppi1979</dc:creator>
      <dc:date>2019-01-03T15:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using the content of a variable for a Macro Call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524302#M142568</link>
      <description>&lt;P&gt;Do you mean you want&amp;nbsp;to generate code something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%comp(datasetname1,PatientOID)&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%comp(datasetname2,PatientOID)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%comp(datasetname3,PatientOID)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;UNTESTED CODE&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    select distinct memname into :names separated by ' ' from dictionary.tables
        where upcase(libname)='P3465_N';
quit;

%macro dothis;
     %do i=1 %to %sysfunc(countw(&amp;amp;names));
         %let thisname=%scan(&amp;amp;names,&amp;amp;i,%str( ));
         %comp(&amp;amp;thisname,PatientOID)
      %end;
%mend;
%dothis&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jan 2019 16:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524302#M142568</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-03T16:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using the content of a variable for a Macro Call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524303#M142569</link>
      <description>&lt;P&gt;yes, … perhaps as a macro that takes eack new Observation of both and writes it&amp;nbsp;as&amp;nbsp;&lt;SPAN&gt;datasetname1&lt;/SPAN&gt;,&lt;SPAN&gt;datasetname2 ...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2019 15:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524303#M142569</guid>
      <dc:creator>struppi1979</dc:creator>
      <dc:date>2019-01-03T15:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using the content of a variable for a Macro Call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524304#M142570</link>
      <description>&lt;P&gt;Message #4 updated to include code.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2019 15:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524304#M142570</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-03T15:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using the content of a variable for a Macro Call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524308#M142572</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to use a reference dataset to generate macro calls ?&lt;/P&gt;
&lt;P&gt;If so, here is a way to achieve this :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro comp(ds=, id=);

    %put &amp;amp;=ds. &amp;amp;=id.;

%mend;

data meta;
    input ds_name $ var_id $;
    cards;
foo x
bar y
baz z
    ;
run;

data _NULL_;
    set meta;
    call execute(cats('%comp(ds=',ds_name,', id=',var_id,');'));
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jan 2019 16:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-content-of-a-variable-for-a-Macro-Call/m-p/524308#M142572</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-01-03T16:06:42Z</dc:date>
    </item>
  </channel>
</rss>

