<?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: Run a Macro by reading from another dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810090#M319460</link>
    <description>&lt;P&gt;So my code should be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename progfile temp;

data _null_;
set combination;
file progfile;
line = cats('%corr(',variable,',',variable_paired,')');
put line;
run;

%include progfile;

filename progfile clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Misunderstandings like this are a main reason why we always ask to provide example data in readily usable form, which means as data steps with datalines.&lt;/P&gt;
&lt;P&gt;We can then simply copy the code to our environment and submit it, and there's no questions at all about dataset names, raw content, variable types and other attributes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your first dataset should be posted as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Date :date9. Variable1 Variable2 Variable3;
format date date9.;
datalines;
31JAN2000 1.3 5.0 9.1
29FEB2000 5.1 6.7 9.8
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Personally, I prefer to use the YYMMDD10. format/informat for dates, as this is the international standard (ISO 8601)&lt;/P&gt;</description>
    <pubDate>Wed, 27 Apr 2022 09:00:59 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-04-27T09:00:59Z</dc:date>
    <item>
      <title>Run a Macro by reading from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810075#M319448</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I am trying to run correlation statistics on all the possible combinations of variables from my dataset. I have already created the possible combinations by joining dataset itself with distinct.&lt;BR /&gt;&lt;BR /&gt;My code is&lt;BR /&gt;&lt;BR /&gt;%MACRO CORR(VAR1, VAR2);&lt;BR /&gt;PROC CORR&lt;BR /&gt;DATA = HAVE&lt;BR /&gt;OUTP = WANT;&lt;BR /&gt;VAR VAR1; WITH VAR2; RUN;&lt;BR /&gt;%MEND;&lt;BR /&gt;&lt;BR /&gt;I am trying to run the macro above by reading up on VAR1 and VAR2 from another dataset using SYSFUNC function.&lt;BR /&gt;&lt;BR /&gt;Appreciate any assistance. Thanks in advance!</description>
      <pubDate>Wed, 27 Apr 2022 07:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810075#M319448</guid>
      <dc:creator>sas51</dc:creator>
      <dc:date>2022-04-27T07:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Macro by reading from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810078#M319451</link>
      <description>&lt;P&gt;Write the code to a file, and include it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename progfile temp;

data _null_;
set have;
file progfile;
line = cats('%corr(',var1,',',var2,')');
put line;
run;

%include progfile;

filename progfile clear;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2022 07:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810078#M319451</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-27T07:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Macro by reading from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810082#M319454</link>
      <description>Hi Kurt, sorry for the confusion, this is how my datasets are now:&lt;BR /&gt;&lt;BR /&gt;Dataset: HAVE&lt;BR /&gt;Date Variable1 Variable2 Variable3 ... Variable10&lt;BR /&gt;31JAN2000 1.3 5.0 9.1 ... 4.3&lt;BR /&gt;29FEB2000 5.1 6.7 9.8 ... 5.1&lt;BR /&gt;&lt;BR /&gt;Dataset: COMBINATION&lt;BR /&gt;Variable Variable_Paired&lt;BR /&gt;Variable1 Variable2&lt;BR /&gt;Variable1 Variable3&lt;BR /&gt;...&lt;BR /&gt;Variable10 Variable9&lt;BR /&gt;&lt;BR /&gt;My combinations (COMBINATION) are in a different dataset as my dataset containing my variables (HAVE).&lt;BR /&gt;&lt;BR /&gt;I am still very new to SYSFUNC are you suggesting something like %SYSFUNC(PROGFILE) in my macro?</description>
      <pubDate>Wed, 27 Apr 2022 08:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810082#M319454</guid>
      <dc:creator>sas51</dc:creator>
      <dc:date>2022-04-27T08:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Macro by reading from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810090#M319460</link>
      <description>&lt;P&gt;So my code should be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename progfile temp;

data _null_;
set combination;
file progfile;
line = cats('%corr(',variable,',',variable_paired,')');
put line;
run;

%include progfile;

filename progfile clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Misunderstandings like this are a main reason why we always ask to provide example data in readily usable form, which means as data steps with datalines.&lt;/P&gt;
&lt;P&gt;We can then simply copy the code to our environment and submit it, and there's no questions at all about dataset names, raw content, variable types and other attributes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your first dataset should be posted as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Date :date9. Variable1 Variable2 Variable3;
format date date9.;
datalines;
31JAN2000 1.3 5.0 9.1
29FEB2000 5.1 6.7 9.8
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Personally, I prefer to use the YYMMDD10. format/informat for dates, as this is the international standard (ISO 8601)&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 09:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810090#M319460</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-27T09:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Macro by reading from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810091#M319461</link>
      <description>&lt;P&gt;PS SYSFUNC does not play any role here.&lt;/P&gt;
&lt;P&gt;%SYSFUNC is a macro function which allows to use (most) data step functions while the macro preprocessor executes macro code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What my code does (in detail):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;it defines a temporary file reference (such a file will reside - invisible to you - in your WORK directory and vanish as soon as your SAS session terminates)&lt;/LI&gt;
&lt;LI&gt;it then writes a series of macro calls to this file&lt;/LI&gt;
&lt;LI&gt;then it includes the file, so the series of macro calls is executed like code you typed into your program&lt;/LI&gt;
&lt;LI&gt;and it finally clears the file reference (in the manner of good house-keeping), causing the file to be deleted right there&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 27 Apr 2022 09:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810091#M319461</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-27T09:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Macro by reading from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810438#M319591</link>
      <description>&lt;P&gt;You can directly read the combinations data set and dynamically make the macro call with call execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UNTESTED&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set combinations;
cmd = cats('%corr(', variable, ',', variable_paired, ');');
*put cmd=;  * confirm syntax;
call execute(cmd);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Apr 2022 18:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810438#M319591</guid>
      <dc:creator>average_joe</dc:creator>
      <dc:date>2022-04-28T18:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Macro by reading from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810452#M319596</link>
      <description>&lt;P&gt;Why do you need such complications?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc corr data=have;
  var variable1-variable10 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Apr 2022 18:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810452#M319596</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-28T18:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Macro by reading from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810593#M319650</link>
      <description>There you go. Knowledge of the procs trumps all nifty programming tricks.</description>
      <pubDate>Fri, 29 Apr 2022 11:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-a-Macro-by-reading-from-another-dataset/m-p/810593#M319650</guid>
      <dc:creator>average_joe</dc:creator>
      <dc:date>2022-04-29T11:58:27Z</dc:date>
    </item>
  </channel>
</rss>

