<?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: automate sas program by using excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314501#M68509</link>
    <description>&lt;P&gt;I use Excel to feed my code, but not store code such as if/then. If you're capable of IF/THEN in Excel, you should be able to in code as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I build my rules based on values I found in a table, otherwise if you need complex logic that can't be handled in Excel, hard code it and DOCUMENT it&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 27 Nov 2016 00:42:06 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-11-27T00:42:06Z</dc:date>
    <item>
      <title>automate sas program by using excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314495#M68508</link>
      <description>&lt;P&gt;Hello experts,&lt;/P&gt;
&lt;P&gt;Please, I want to know from your experience( coding, performance)&amp;nbsp; about the automating of sas program fom excel.&lt;/P&gt;
&lt;P&gt;I want to use sas code in excel&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="319"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="80"&gt;table&lt;/TD&gt;
&lt;TD width="80"&gt;vaiable&lt;/TD&gt;
&lt;TD width="159"&gt;sas_code_rule&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;T1&lt;/TD&gt;
&lt;TD&gt;tv1&lt;/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>
      <pubDate>Sat, 26 Nov 2016 23:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314495#M68508</guid>
      <dc:creator>LineMoon</dc:creator>
      <dc:date>2016-11-26T23:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: automate sas program by using excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314501#M68509</link>
      <description>&lt;P&gt;I use Excel to feed my code, but not store code such as if/then. If you're capable of IF/THEN in Excel, you should be able to in code as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I build my rules based on values I found in a table, otherwise if you need complex logic that can't be handled in Excel, hard code it and DOCUMENT it&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 00:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314501#M68509</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-27T00:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: automate sas program by using excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314506#M68512</link>
      <description>&lt;P&gt;In my experience using Excel as the source for "code injection" and parameter driven generation of dynamic code, is not a good approach. Having said that, I had lately to implement something similar for a very special use case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would go for a 2 step approach.&lt;/P&gt;
&lt;P&gt;1. Load your data from Excel into a permanent SAS table. This process should also do some syntax validation. You could for example generate a data _null_ step and execute all your code in there. Only load the new data into the permanent parameter table if this data _null_ step executes without any errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Generate your dynamic code using the permanent SAS table. Below a code sample which might get you started.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* excel data loaded into SAS work table */
data excel_source;
  infile datalines4 truncover dlm=',' dsd ;
  input table:$41. variable:$32. code:$200.;
  datalines4;
sashelp.class,age,if age&amp;lt;15 then age=10; else age=20;
sashelp.othertable,age,if age=99
sashelp.class,sex,if sex='M' then sex='m';
;;;;
run;

/* syntax check source data */
filename codechk temp;
data _null_;
  file codechk;
  set excel_source end=last;
  if _n_=1 then put 'data _null_;';
  put @3 code;
  if last then put 'run;';
run;
%include codechk /source2;

/* only load parameter table if there is no error */
data param;
  set excel_source;
run;

/* sample for dynamic code */
filename codegen temp;
data _null_;
  file codegen;
  set param(where=(upcase(table)=upcase("SASHELP.CLASS"))) end=last;

  if _n_=1 then
    do;
      put 
          'data want;'
        / '  set ' table ';'
        ;
      end;
  put @3 code;
  if last then
    do;
      put 'run;';
    end;
run;

%include codegen /source2;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;...but again: I'd consider such an approach only as the right thing to do in very rare and "exotic" circumstances. What's your use case for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 00:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314506#M68512</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-27T00:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: automate sas program by using excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314577#M68530</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt; Thank you for answer.&lt;/P&gt;
&lt;P&gt;But I think , we can use mask functions to use code-importing from excel ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 10:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314577#M68530</guid>
      <dc:creator>LineMoon</dc:creator>
      <dc:date>2016-11-27T10:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: automate sas program by using excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314578#M68531</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick﻿&lt;/a&gt; Thank you Patrick, that's nice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; So, what's about the sas mask functions and sas rules in excel ?&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 10:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314578#M68531</guid>
      <dc:creator>LineMoon</dc:creator>
      <dc:date>2016-11-27T10:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: automate sas program by using excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314579#M68532</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44053"&gt;@LineMoon﻿&lt;/a&gt;&amp;nbsp;Not sure that I understand your question? Can you please elaborate a bit more?&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 10:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314579#M68532</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-27T10:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: automate sas program by using excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314581#M68534</link>
      <description>&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick﻿&lt;/a&gt; Sorry for that,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ok, I will do&lt;/P&gt;
&lt;P&gt;if the excel column "sas_code_rule" contains a sas code with :&amp;nbsp; if,&amp;nbsp; then, do, while, for , when, set, contain, like, end, or&amp;nbsp; .....&lt;/P&gt;
&lt;P&gt;after the importing, I need to mask the code during the compilation by the mask function %quote, %nrquote,... ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="319"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="80"&gt;table&lt;/TD&gt;
&lt;TD width="80"&gt;vaiable&lt;/TD&gt;
&lt;TD width="159"&gt;sas_code_rule&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;T1&lt;/TD&gt;
&lt;TD&gt;tv1&lt;/TD&gt;
&lt;TD&gt;if tv2=2 then tv1=0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;T1&lt;/TD&gt;
&lt;TD&gt;tv2&lt;/TD&gt;
&lt;TD&gt;when….case... do&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;T1&lt;/TD&gt;
&lt;TD&gt;tv3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;T1&lt;/TD&gt;
&lt;TD&gt;tv4&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Tn&lt;/TD&gt;
&lt;TD&gt;tv1&lt;/TD&gt;
&lt;TD&gt;if tv2=2 then tv1=0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Tn&lt;/TD&gt;
&lt;TD&gt;tv2&lt;/TD&gt;
&lt;TD&gt;when….case... do&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Tn&lt;/TD&gt;
&lt;TD&gt;tv3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Tn&lt;/TD&gt;
&lt;TD&gt;tv4&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Tn&lt;/TD&gt;
&lt;TD&gt;tv5&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Sun, 27 Nov 2016 10:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314581#M68534</guid>
      <dc:creator>LineMoon</dc:creator>
      <dc:date>2016-11-27T10:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: automate sas program by using excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314584#M68537</link>
      <description>&lt;P&gt;You don't need any masking with the code sample I've posted. Everything is treated as text only. Compilation of the data step only happens as part of the %include statement - and there you want the SAS statements to get compiled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you generating the code so that you need macro level masking?&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 11:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314584#M68537</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-27T11:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: automate sas program by using excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314587#M68540</link>
      <description>&lt;P&gt;Sorry, I do not understand well your question ?&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 11:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automate-sas-program-by-using-excel/m-p/314587#M68540</guid>
      <dc:creator>LineMoon</dc:creator>
      <dc:date>2016-11-27T11:30:57Z</dc:date>
    </item>
  </channel>
</rss>

