<?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: Generate Dynamic Code in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Generate-Dynamic-Code/m-p/434775#M28089</link>
    <description>&lt;P&gt;I am interpreting the question you are asking a little differently.&amp;nbsp; I think you want to make the "generated code" available at a later date.&amp;nbsp; For example, here is how the program could construct a separate file holding the generated code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;set rule;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;file 'path to some file of your choice' noprint;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;put "if val1='" val1 +(-1) "' and val2='" val2 +(-1)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; "' and val3='" val3 +(-1) "' and val4='" val4 +(-1) "' then";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;put "&amp;nbsp; &amp;nbsp;do;"&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; / "&amp;nbsp; &amp;nbsp;end;"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; / ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As with any long series of IF/THEN statements, consider whether it would be wise to add the word ELSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When this DATA step is over, the file that you have specified in quotes in the FILE statement will hold the code you are asking for.&amp;nbsp; You might edit that code to fill in what needs to be done, before %INCLUDE brings it in.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Feb 2018 07:26:52 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-02-07T07:26:52Z</dc:date>
    <item>
      <title>Generate Dynamic Code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Generate-Dynamic-Code/m-p/434769#M28087</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I have data set and i want to generate dynamic code is it possible&amp;nbsp; to generate dynamic code from existing sas data sets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the datatsets .&lt;/P&gt;&lt;P&gt;DATA rule;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;INFILE DATALINES DELIMITER=',' DSD;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;INPUT val1 $ val2 $ val3 $ val4 $;&lt;BR /&gt;DATALINES;&lt;BR /&gt;1,,3,4&lt;BR /&gt;68,89,80,,&lt;BR /&gt;87,,,12&lt;BR /&gt;RUN;&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="rule.PNG" style="width: 393px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18364i69CF91DB3E7EE98C/image-size/large?v=v2&amp;amp;px=999" role="button" title="rule.PNG" alt="rule.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;i want to generate dynamic code like multiple if condition is given below for above data set. is it possible to generate if data is very large and have many different number of combinations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;if val1='1' and val2='' and val3='3' val4='4' then&lt;BR /&gt;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if val1='68' and val2='89' and val3='80' val4='' then&lt;BR /&gt;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if val1='87' and val2='' and val3='' val4='12' then&lt;BR /&gt;do;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 06:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Generate-Dynamic-Code/m-p/434769#M28087</guid>
      <dc:creator>ramanandyadav</dc:creator>
      <dc:date>2018-02-07T06:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Dynamic Code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Generate-Dynamic-Code/m-p/434774#M28088</link>
      <description>&lt;P&gt;Follow the basic macro development scheme:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;write s single instance of code, and make it work&lt;/LI&gt;
&lt;LI&gt;identify parts that need to change&lt;/LI&gt;
&lt;LI&gt;replace by macro variables, set the macrovars, test again&lt;/LI&gt;
&lt;LI&gt;wrap into a macro definition, supply the macrovars as parameters, test again&lt;/LI&gt;
&lt;LI&gt;add macro code for more complex code generation&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Once such a macro works, you can create a control dataset that contains your series of parameters, and use call execute off that.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 07:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Generate-Dynamic-Code/m-p/434774#M28088</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-07T07:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Dynamic Code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Generate-Dynamic-Code/m-p/434775#M28089</link>
      <description>&lt;P&gt;I am interpreting the question you are asking a little differently.&amp;nbsp; I think you want to make the "generated code" available at a later date.&amp;nbsp; For example, here is how the program could construct a separate file holding the generated code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;set rule;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;file 'path to some file of your choice' noprint;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;put "if val1='" val1 +(-1) "' and val2='" val2 +(-1)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; "' and val3='" val3 +(-1) "' and val4='" val4 +(-1) "' then";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;put "&amp;nbsp; &amp;nbsp;do;"&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; / "&amp;nbsp; &amp;nbsp;end;"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; / ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As with any long series of IF/THEN statements, consider whether it would be wise to add the word ELSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When this DATA step is over, the file that you have specified in quotes in the FILE statement will hold the code you are asking for.&amp;nbsp; You might edit that code to fill in what needs to be done, before %INCLUDE brings it in.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 07:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Generate-Dynamic-Code/m-p/434775#M28089</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-07T07:26:52Z</dc:date>
    </item>
  </channel>
</rss>

