<?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: Efficiency Analysis: Run Analysis by year and region in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Efficiency-Analysis-Run-Analysis-by-year-and-region/m-p/905171#M4056</link>
    <description>&lt;P&gt;Your CREATE DATA statement does not include year and region and also gets overwritten each time you call the macro.&amp;nbsp; The following code does what I think you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*      create data efficiency_data from [garage] garage_name efficiency_number ;*/
      create data efficiency_data from [garage] year=&amp;amp;year region="&amp;amp;region" garage_name efficiency_number ;
   quit;

   proc append base=efficiency_data_all data=efficiency_data;
   run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_045/ormpex/ormpex_ex22_toc.htm" target="_blank"&gt;SAS Help Center: Efficiency Analysis: How to Use Data Envelopment Analysis to Compare Efficiencies of Garages&lt;/A&gt;&amp;nbsp;for a related documentation example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS Viya, you can instead use the groupBy= parameter in the runOptmodel action to automate the BY-group processing:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_045/casactmopt/casactmopt_optimization_details05.htm" target="_blank"&gt;SAS Help Center: BY-Group Processing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2023 14:43:31 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2023-11-29T14:43:31Z</dc:date>
    <item>
      <title>Efficiency Analysis: Run Analysis by year and region</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Efficiency-Analysis-Run-Analysis-by-year-and-region/m-p/905141#M4055</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following code from this community. When I run the code, it works, but I find that it does not give efficiency scores by year and region. Any help would be greatly appreciated. Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data inputs;&lt;BR /&gt;input input $8.;&lt;BR /&gt;datalines;&lt;BR /&gt;staff&lt;BR /&gt;showroom&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data outputs;&lt;BR /&gt;input output $10.;&lt;BR /&gt;datalines;&lt;BR /&gt;beta_sales&lt;BR /&gt;profit&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data garage_data;&lt;BR /&gt;input garage_name $ year region $ staff showroom alpha_sales beta_sales profit;&lt;BR /&gt;datalines;&lt;BR /&gt;Winchester 2020 A 7 8 10 12 8.5 4 2 0.6 1.5&lt;BR /&gt;Andover 2020 A 6 6 20 30 9 4.5 2.3 0.7 1.6&lt;BR /&gt;Basingstoke 2020 B 2 3 40 40 2 1.5 0.8 0.25 0.5&lt;BR /&gt;Poole 2020 B 14 9 20 25 10 6 2.6 0.86 1.9&lt;BR /&gt;Winchester 2021 A 10 9 10 10 11 5 2.4 1 2&lt;BR /&gt;Andover 2021 A 24 15 15 13 25 19 8 2.6 4.5&lt;BR /&gt;Basingstoke 2021 B 6 7 50 40 8.5 3 2.5 0.9 1.6&lt;BR /&gt;Poole 2021 B 8 7.5 5 8 9 4 2.1 0.85 2&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=garage_data;&lt;BR /&gt;by year region;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data garage_data1;&lt;BR /&gt;set garage_data(keep=year region);&lt;BR /&gt;by year region;&lt;BR /&gt;if first.region;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro compute(year=,region=);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc optmodel ;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;set &amp;lt;str&amp;gt; INPUTS;&lt;BR /&gt;read data inputs into INPUTS=[input];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set &amp;lt;str&amp;gt; OUTPUTS;&lt;/P&gt;
&lt;P&gt;read data outputs into OUTPUTS=[output];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set &amp;lt;num&amp;gt; GARAGES ;&lt;/P&gt;
&lt;P&gt;str garage_name {GARAGES};&lt;BR /&gt;num input {INPUTS, GARAGES};&lt;BR /&gt;num output {OUTPUTS, GARAGES};&lt;BR /&gt;read data garage_data(where=(year=&amp;amp;year and region="&amp;amp;region")) into GARAGES=[_N_] garage_name&lt;BR /&gt;{i in INPUTS} &amp;lt;input[i,_N_]=col(i)&amp;gt;&lt;BR /&gt;{i in OUTPUTS} &amp;lt;output[i,_N_]=col(I)&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;num k;&lt;BR /&gt;num efficiency_number {GARAGES};&lt;BR /&gt;num weight_sol {GARAGES, GARAGES};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var Weight {GARAGES} &amp;gt;= 0;&lt;BR /&gt;var Inefficiency &amp;gt;= 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;max Objective = Inefficiency;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;con Input_con {i in INPUTS}:&lt;BR /&gt;sum {j in GARAGES} input[i,j] * Weight[j] &amp;lt;= input[i,k];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;con Output_con {i in OUTPUTS}:&lt;BR /&gt;sum {j in GARAGES} output[i,j] * Weight[j] &amp;gt;= output[i,k] * Inefficiency;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do k = GARAGES;&lt;BR /&gt;solve;&lt;BR /&gt;efficiency_number[k] = 1 / Inefficiency.sol;&lt;BR /&gt;for {j in GARAGES}&lt;BR /&gt;weight_sol[k,j] = (if Weight[j].sol &amp;gt; 1e-6 then Weight[j].sol else .);&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;print garage_name efficiency_number;&lt;BR /&gt;create data efficiency_data from [garage] garage_name efficiency_number ;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;set garage_data1;&lt;BR /&gt;call execute(cats('%nrstr(%compute(year=',year,',region=',region,'))'));&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 11:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Efficiency-Analysis-Run-Analysis-by-year-and-region/m-p/905141#M4055</guid>
      <dc:creator>Zakir</dc:creator>
      <dc:date>2023-11-29T11:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Analysis: Run Analysis by year and region</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Efficiency-Analysis-Run-Analysis-by-year-and-region/m-p/905171#M4056</link>
      <description>&lt;P&gt;Your CREATE DATA statement does not include year and region and also gets overwritten each time you call the macro.&amp;nbsp; The following code does what I think you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*      create data efficiency_data from [garage] garage_name efficiency_number ;*/
      create data efficiency_data from [garage] year=&amp;amp;year region="&amp;amp;region" garage_name efficiency_number ;
   quit;

   proc append base=efficiency_data_all data=efficiency_data;
   run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_045/ormpex/ormpex_ex22_toc.htm" target="_blank"&gt;SAS Help Center: Efficiency Analysis: How to Use Data Envelopment Analysis to Compare Efficiencies of Garages&lt;/A&gt;&amp;nbsp;for a related documentation example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS Viya, you can instead use the groupBy= parameter in the runOptmodel action to automate the BY-group processing:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_045/casactmopt/casactmopt_optimization_details05.htm" target="_blank"&gt;SAS Help Center: BY-Group Processing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 14:43:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Efficiency-Analysis-Run-Analysis-by-year-and-region/m-p/905171#M4056</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2023-11-29T14:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiency Analysis: Run Analysis by year and region</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Efficiency-Analysis-Run-Analysis-by-year-and-region/m-p/905220#M4057</link>
      <description>&lt;P&gt;Thank you so much, Rob. I greatly appreciate your help. Regards.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 17:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Efficiency-Analysis-Run-Analysis-by-year-and-region/m-p/905220#M4057</guid>
      <dc:creator>Zakir</dc:creator>
      <dc:date>2023-11-29T17:24:03Z</dc:date>
    </item>
  </channel>
</rss>

