<?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: Storing logic in a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571615#M161254</link>
    <description>&lt;P&gt;You can use DOSUBL like the example.&amp;nbsp; However it is usually better to write code that will compile the logic in a "regular" data step.&amp;nbsp; But DOSUBL is fun so...\&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
   length additional_logic $50;
   input additional_logic $;
   datalines;
day(today())=6
day(today())^=6
;;;;
%global additional_logic;
data tf;
   set x;
   todo=catx(' ','data _null_; call symputx("additional_logic",',additional_logic,'); stop; run;');
   rc = dosubl(todo);
   TrueFalse=symgetn('additional_logic');
   put _all_;
   run;
%put _user_;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30807i8FC010B28E9D9AB4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Jul 2019 21:55:50 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2019-07-06T21:55:50Z</dc:date>
    <item>
      <title>Storing logic in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571605#M161252</link>
      <description>&lt;P&gt;I have a data set, created from an Excel file, where logic is stored in a character variable named additional_logic. I am trying to resolve that logic in another variable--e.g. in the below example, TrueFlase would equal 0 or 1. I thought this would be simple, but I can't seem to find anything that works. I've tried IFN, I've tried CALL SYMPUTX + SYMGET to no avail. Any guidance is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
length additional_logic $50;
input additional_logic $;
datalines;
put(today(),day.)=6
put(today(),day.)^=6
;

data _null_;
set x;
call symputx('additional_logic',additional_logic);
TrueFalse=symget('additional_logic');
put TrueFalse;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Jul 2019 20:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571605#M161252</guid>
      <dc:creator>Mike_B</dc:creator>
      <dc:date>2019-07-06T20:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Storing logic in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571615#M161254</link>
      <description>&lt;P&gt;You can use DOSUBL like the example.&amp;nbsp; However it is usually better to write code that will compile the logic in a "regular" data step.&amp;nbsp; But DOSUBL is fun so...\&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
   length additional_logic $50;
   input additional_logic $;
   datalines;
day(today())=6
day(today())^=6
;;;;
%global additional_logic;
data tf;
   set x;
   todo=catx(' ','data _null_; call symputx("additional_logic",',additional_logic,'); stop; run;');
   rc = dosubl(todo);
   TrueFalse=symgetn('additional_logic');
   put _all_;
   run;
%put _user_;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30807i8FC010B28E9D9AB4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2019 21:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571615#M161254</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-07-06T21:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Storing logic in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571678#M161286</link>
      <description>&lt;P&gt;The easiest way to apply these pieces of logic is to split the processing:&amp;nbsp; one DATA step to bring in the formulas, and a second DATA step to apply them.&amp;nbsp; Here is a simplified version (since it doesn't automate the number of formulas to apply):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length additional_logic $50;
input additional_logic $;
call symputx(cats('v', _n_), additional_logic);
datalines;
put(today(),day.)=6
put(today(),day.)^=6
;

data want;
   set have;
   TrueFalse1 = &amp;amp;v1;
   TrueFalse2 = &amp;amp;v2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jul 2019 00:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571678#M161286</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-07-08T00:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Storing logic in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571698#M161300</link>
      <description>Could be task for resolve function.</description>
      <pubDate>Mon, 08 Jul 2019 05:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571698#M161300</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-08T05:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Storing logic in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571745#M161316</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/97807"&gt;@Mike_B&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find it personally often easiest to first generate the dynamic code into a file and then %include the file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fromExcel;
   length additional_logic $50;
   input additional_logic $;
   datalines;
day(today())=6
day(today())^=6
;;;;

filename codegen temp;
data _null_;
  file codegen;
/*  file print;*/
  set fromExcel;
  put 'TrueFalse_' _n_ z3. '=' additional_logic ';';
run;

data want;
  set sashelp.class;
  %include codegen / source2;
run;
filename codegen clear;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jul 2019 11:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/571745#M161316</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-07-08T11:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Storing logic in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/572539#M161569</link>
      <description>Thank you. This worked great. All of the proposed solutions worked--Patrick's include file method was pretty cool--but this one allowed me to not have to write additional data steps/macros.</description>
      <pubDate>Wed, 10 Jul 2019 21:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-logic-in-a-variable/m-p/572539#M161569</guid>
      <dc:creator>Mike_B</dc:creator>
      <dc:date>2019-07-10T21:42:34Z</dc:date>
    </item>
  </channel>
</rss>

