<?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: DS2 and usage of variable values in methods as code similar to macros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475940#M122421</link>
    <description>&lt;P&gt;I thought that would be the case - I've seen systems like that before and they work well as long as the user understands the syntax for the rules and the rules are fairly simple. I think my first suggestion is probably your optimal solution.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jul 2018 10:03:23 GMT</pubDate>
    <dc:creator>ChrisBrooks</dc:creator>
    <dc:date>2018-07-06T10:03:23Z</dc:date>
    <item>
      <title>DS2 and usage of variable values in methods as code similar to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475826#M122378</link>
      <description>&lt;P&gt;The subject may be a little confusing but here is what I want to achive with DS2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset containing a field which contains values I want to use as code, when invoking a method in ds2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In case of a macro I would use something like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro subu(ruu1);&lt;BR /&gt;	data test;&lt;BR /&gt;		set sas_data.orders;&lt;BR /&gt;&lt;BR /&gt;		if &amp;amp;ruu1. then output;&lt;BR /&gt;	run;&lt;BR /&gt;%mend subu;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;	set testdat;&lt;BR /&gt;	&lt;BR /&gt;	call execute('%subu('||vari||')');&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;In this case dataset testdat only having one obs and one variable &lt;EM&gt;vari&lt;/EM&gt; which contains the value: &lt;STRONG&gt;ordertype eq 3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an option in ds2 to call a method with field values of a dataset as parameters which could be used as code it executes in said method?&lt;/P&gt;&lt;P&gt;Or can macros be called from a ds2 anyhow?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 07:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475826#M122378</guid>
      <dc:creator>Alkibiades</dc:creator>
      <dc:date>2018-07-06T07:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: DS2 and usage of variable values in methods as code similar to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475928#M122411</link>
      <description>&lt;P&gt;The simplest way might be to load your rules into macro variables before your Proc DS2 step and then using them as in this example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rules;
	length rulename $6 ruleval $20;
	infile datalines dlm=",";
	input rulename ruleval;
	datalines;
rule1,age&amp;gt;12
rule2,height&amp;gt;60
;
run;

data class;
	set sashelp.class;
run;

/* Load rules into macro variables */

data _null_;
	set rules;
	call symput(rulename,ruleval);
run;


/* DS2 Program */

proc ds2;
	
data out(overwrite=yes);

  method run();
  
    set class;
    
    if &amp;amp;rule1 and &amp;amp;rule2 then output;
  end;

  method term();
  end;
enddata;
run; quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have done similar things in old school "classic" data step and as I'm sure you're aware it can become very complicated very quickly...&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 08:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475928#M122411</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2018-07-06T08:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: DS2 and usage of variable values in methods as code similar to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475932#M122414</link>
      <description>&lt;P&gt;An exellent suggestion, thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason why I so desperately search for a method to incorporate macro functionality in ds2 programming is that I am the first in my department starting to deal with ds2 and I would love to have good arguments praising its versatility to make it popular amongst my collagues.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 09:21:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475932#M122414</guid>
      <dc:creator>Alkibiades</dc:creator>
      <dc:date>2018-07-06T09:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: DS2 and usage of variable values in methods as code similar to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475933#M122415</link>
      <description>&lt;P&gt;You can create DS2 packages which are in effect method libraries&amp;nbsp;and which would replace traditional macros. That, I think, might be the best way forward rather than trying to shoehorn macros into a scenario they weren't really designed for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option might be to create FCMP functions which can themselves call macros but the calling syntax is somewhat different for those macros.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 09:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475933#M122415</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2018-07-06T09:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: DS2 and usage of variable values in methods as code similar to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475935#M122416</link>
      <description>&lt;P&gt;I already considered FCMP functions but wanted to find a way especially in ds2 because there are plenty of validy checks for data I could very nicely do with methods. The challenge to me is how to use field values from datasets (I created from importing data from Excel control sheets) as code itself.&lt;/P&gt;&lt;P&gt;The user maintaining the mentioned control sheets so to say enters rules in fields that are to be applied as code to validate data by my program.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 09:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475935#M122416</guid>
      <dc:creator>Alkibiades</dc:creator>
      <dc:date>2018-07-06T09:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: DS2 and usage of variable values in methods as code similar to macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475940#M122421</link>
      <description>&lt;P&gt;I thought that would be the case - I've seen systems like that before and they work well as long as the user understands the syntax for the rules and the rules are fairly simple. I think my first suggestion is probably your optimal solution.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 10:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DS2-and-usage-of-variable-values-in-methods-as-code-similar-to/m-p/475940#M122421</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2018-07-06T10:03:23Z</dc:date>
    </item>
  </channel>
</rss>

