<?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: Can an expert tell me what this principle is? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871603#M344335</link>
    <description>Thank You for your answer,I will try</description>
    <pubDate>Mon, 24 Apr 2023 14:35:33 GMT</pubDate>
    <dc:creator>_Sas_Beginner_</dc:creator>
    <dc:date>2023-04-24T14:35:33Z</dc:date>
    <item>
      <title>Can an expert tell me what this principle is?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871548#M344302</link>
      <description>&lt;P&gt;I found a bug about SAS, a data step in a macro runs the dosubl function, the dosubl function calls the FCMP function, and the FCMP function runs the macro, which will cause the crash problem!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*this is macro*/
%MACRO SORTS;
%LET INPUT_TABLE=%SYSFUNC(DEQUOTE(&amp;amp;INPUT_TABLE));
	%LET VARIABLE=%SYSFUNC(DEQUOTE(&amp;amp;VARIABLE));
PROC SORT DATA=&amp;amp;INPUT_TABLE;
	BY &amp;amp;VARIABLE;
 RUN;
%MEND SORTS;

/*this is fcmp function*/
PROC FCMP OUTLIB=WORK.FUNCS.MATH;
	FUNCTION SORTS_MACRO(INPUT_TABLE $,VARIABLE $);
		RC=RUN_MACRO('SORTS',INPUT_TABLE,VARIABLE);
		RETURN(RC);
	ENDSUB;

/*this is data step and new macro*/
OPTION CMPLIB=(WORK.FUNCS);
DATA _NULL_;
RC=DOSUBL("
	PROC CLUSTER DATA =&amp;amp;DATANAME METHOD=MCQUITTY SIMPLE CCC STD RSQUARE PSEUDO OUTTREE=&amp;amp;OUTNAME1;
		VAR _2021 _2020 _2019 _2018;
			ID CITY;
	RUN;
PROC TREE DATA=&amp;amp;OUTNAME1 OUT=&amp;amp;OUTNAME2 NCLUSTERS=3;
	ID CITY;
RUN; 
OPTIONS CMPLIB=WORK.FUNCS;
DATA  _NULL_;
	RC=SORTS_MACRO('&amp;amp;DATANAME','CITY');
		RC=SORTS_MACRO('&amp;amp;OUTNAME2','CITY');
RUN;");

RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 11:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871548#M344302</guid>
      <dc:creator>_Sas_Beginner_</dc:creator>
      <dc:date>2023-04-24T11:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can an expert tell me what this principle is?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871551#M344303</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*This is how the last step should be*/
%MACRO CLUSTERS (DATANAME,OUTNAME1,OUTNAME2,OUTNAME3,FILE);
OPTION CMPLIB=(WORK.FUNCS);
DATA _NULL_;
RC=DOSUBL("
	PROC CLUSTER DATA =&amp;amp;DATANAME METHOD=MCQUITTY SIMPLE CCC STD RSQUARE PSEUDO OUTTREE=&amp;amp;OUTNAME1;
		VAR _2021 _2020 _2019 _2018;
			ID CITY;
	RUN;
PROC TREE DATA=&amp;amp;OUTNAME1 OUT=&amp;amp;OUTNAME2 NCLUSTERS=3;
	ID CITY;
RUN; 
OPTIONS CMPLIB=WORK.FUNCS;
DATA  _NULL_;
	RC=SORTS_MACRO('&amp;amp;DATANAME','CITY');
		RC=SORTS_MACRO('&amp;amp;OUTNAME2','CITY');
RUN;");

RUN;

%CLUSTERS(SASMAP.CLUSTERS,CLUST,TERR,SGPLOT,CLUSTERS.RTF);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Apr 2023 12:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871551#M344303</guid>
      <dc:creator>_Sas_Beginner_</dc:creator>
      <dc:date>2023-04-24T12:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can an expert tell me what this principle is?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871556#M344306</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;right now and with the information you provided, I can not say if and why it would make sense to write code in this way and not like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO CLUSTERS (DATANAME,OUTNAME1,OUTNAME2,OUTNAME3,FILE);
      PROC CLUSTER DATA =&amp;amp;DATANAME. METHOD=MCQUITTY SIMPLE CCC STD RSQUARE PSEUDO OUTTREE=&amp;amp;OUTNAME1.;
      	VAR _2021 _2020 _2019 _2018;
      	ID CITY;
      RUN;
      PROC TREE DATA=&amp;amp;OUTNAME1. OUT=&amp;amp;OUTNAME2. NCLUSTERS=3;
      	ID CITY;
      RUN; 
      PROC SORT DATA=&amp;amp;DATANAME.;
      	BY CITY;
      RUN;
%MEND CLUSTERS;

%CLUSTERS(SASMAP.CLUSTERS,CLUST,TERR,SGPLOT,CLUSTERS.RTF;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 12:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871556#M344306</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2023-04-24T12:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can an expert tell me what this principle is?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871557#M344307</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434736"&gt;@_Sas_Beginner_&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I personally would try to avoid all this convoluted mixture of techniques!&lt;/P&gt;
&lt;P&gt;Try to simplify and isolate operations into their own individual units/functions/macros if you can, here is why&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;It will provide better traceable/understandable code. Think of who will have to take over your code in the future&lt;/LI&gt;
&lt;LI&gt;When code modules are separated/decoupled, they can work in parallel as and when needed&lt;/LI&gt;
&lt;LI&gt;SAS provided various ways to run custom code, but that doesn't mean one should mix them just for the sake of it. Always try to think "Horses for Courses". i.e. choose the right technique for the right purpose.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Take a step back, and re-analyze what's your ultimate goal from your custom code, and reevaluate what needs to be coupled vs. decoupled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is all I can advice you with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 12:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871557#M344307</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-04-24T12:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can an expert tell me what this principle is?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871561#M344311</link>
      <description>&lt;P&gt;Why you want it to be so over-ove-over-complicated?? (yes, I repeated it 3 times)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can achieve the same effect by simple:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* sorting macro*/
%MACRO SORTS(INPUT_TABLE,VARIABLE);
PROC SORT DATA=&amp;amp;INPUT_TABLE;
	BY &amp;amp;VARIABLE;
 RUN;
%MEND SORTS;


/* This is how the last step should be... */
%MACRO CLUSTERS (DATANAME,OUTNAME1,OUTNAME2,OUTNAME3,FILE);
PROC CLUSTER DATA =&amp;amp;DATANAME METHOD=MCQUITTY SIMPLE CCC STD RSQUARE PSEUDO OUTTREE=&amp;amp;OUTNAME1;
  VAR _2021 _2020 _2019 _2018;
  ID CITY;
	RUN;

PROC TREE DATA=&amp;amp;OUTNAME1 OUT=&amp;amp;OUTNAME2 NCLUSTERS=3;
	ID CITY;
RUN; 

%SORTS(&amp;amp;DATANAME,CITY)
%SORTS(&amp;amp;OUTNAME2,CITY)
%mend;

%CLUSTERS(SASMAP.CLUSTERS,CLUST,TERR,SGPLOT,CLUSTERS.RTF);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;No FCMP, run_macro(), etc.&amp;nbsp; (in this situation absolutely unnecessary).&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 12:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871561#M344311</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-04-24T12:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can an expert tell me what this principle is?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871603#M344335</link>
      <description>Thank You for your answer,I will try</description>
      <pubDate>Mon, 24 Apr 2023 14:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871603#M344335</guid>
      <dc:creator>_Sas_Beginner_</dc:creator>
      <dc:date>2023-04-24T14:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can an expert tell me what this principle is?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871606#M344338</link>
      <description>thanks for You..reply,I will.try it</description>
      <pubDate>Mon, 24 Apr 2023 14:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-an-expert-tell-me-what-this-principle-is/m-p/871606#M344338</guid>
      <dc:creator>_Sas_Beginner_</dc:creator>
      <dc:date>2023-04-24T14:36:41Z</dc:date>
    </item>
  </channel>
</rss>

