<?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: Iteration to change macro names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795295#M255070</link>
    <description>&lt;P&gt;Thanks Reeza ..&lt;/P&gt;&lt;P&gt;I am getting some error messaged on&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;25 GOPTIONS ACCESSIBLE;&lt;BR /&gt;ERROR: All positional parameters must precede keyword parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;84 %analysis(ClusterGrp = Cluster1, Finalf_ = Final1, finalMean = DIAB001);&lt;BR /&gt;_&lt;BR /&gt;180&lt;BR /&gt;WARNING: Apparent invocation of macro ANALYSIS not resolved.&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;WARNING: Apparent invocation of macro ANALYSIS not resolved.&lt;BR /&gt;85 %analysis(ClusterGrp = Cluster2, Finalf_ = Final2, finalMean = DIAB001);&lt;BR /&gt;_&lt;BR /&gt;180&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;1                                                          The SAS System                          10:29 Wednesday, February 9, 2022

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
4          %LET _CLIENTPROCESSFLOWNAME='Cluster - Optimization';
5          %LET _CLIENTPROJECTPATH='C:\Users\up0j1eb\Desktop\SNP Simulations\Cut_point_simulation_20220203_AY003.egp';
6          %LET _CLIENTPROJECTPATHHOST='HPZ155CG0502B2G';
7          %LET _CLIENTPROJECTNAME='Cut_point_simulation_20220203_AY003.egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HtmlBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome94/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&amp;amp;sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
ERROR: All positional parameters must precede keyword parameters.
26         %macro analysis(clustergrp = , finalf_ , finalMean= );
27         
28         data WORK.inclusterdat_random9;
29         	set &amp;amp;ClusterGrp.;
30         run;
31         
32         /*STANDARD CLUSTERING ALGORITHM*/
33         /*STEP 3*/
34         /*Measure Euclidean distance between data points*/
35         proc distance
36         	data=WORK.inclusterdat_random9
37         	out=distancedat
38         	method=Euclid;
39         	var interval(METRIC);
40         	id contract_id;
41         run;
42         
43         /*STEP 4*/
44         /*cluster creation using Ward's minimum variance*/
45         proc cluster data=distancedat method=ward /*trim=1 k=3*/
46         	outtree=treedat noprint;
47         	id contract_id;
48         run;
49         
50         /*STEP 5*/
51         /* replace NSTARS with numeric constant (# of star levels = 5)*/
52         proc tree data=treedat ncl=5 horizontal out=outclusterdat noprint;
53         	id contract_id;
54         run;
55         
56         /*STEP 6*/
2                                                          The SAS System                          10:29 Wednesday, February 9, 2022

57         /*Join measure score to distinct cluster groupings*/
58         proc sql;
59         	CREATE TABLE WORK.JOIN AS
60         		SELECT a.*,
61         			b.METRIC
62         		FROM work.outclusterdat a INNER JOIN WORK.inclusterdat_random9 b
63         			ON a.contract_id = b.contract_id
64         		order by CLUSTER DESC;
65         
66         	/*STEP7*/
67         	/*Create upper bound threshold cutoff*/
68         	/*NOTE***Cluster output is naturally unordered so it needs to be reordered depending on measure (higher=better or
68       ! lower=better)***/
69         	/*NAME OUT FILE TO NEW DATASET HERE */
70         	/*This step needs to by run multiple times to create the followig files - */
71         proc sql;
72         	CREATE TABLE &amp;amp;Finalf_. AS
73         		SELECT DISTINCT cluster,
74         			MIN(METRIC) AS LOWER_BOUND
75         		FROM WORK.JOIN
76         			WHERE cluster BETWEEN 1 AND 5
77         				GROUP BY cluster
78         					ORDER BY LOWER_BOUND ASC;
79         quit;
80         
81         %mend;
82         /*Call macro multiple times:*/
83         
84         %analysis(ClusterGrp = Cluster1, Finalf_ = Final1, finalMean = DIAB001);
           _
           180
WARNING: Apparent invocation of macro ANALYSIS not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
85         %analysis(ClusterGrp = Cluster2, Finalf_ = Final2, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

86         
87         
88         
89         
90         GOPTIONS NOACCESSIBLE;
91         %LET _CLIENTTASKLABEL=;
92         %LET _CLIENTPROCESSFLOWNAME=;
93         %LET _CLIENTPROJECTPATH=;
94         %LET _CLIENTPROJECTPATHHOST=;
95         %LET _CLIENTPROJECTNAME=;
96         %LET _SASPROGRAMFILE=;
97         %LET _SASPROGRAMFILEHOST=;
98         
99         ;*';*";*/;quit;run;
100        ODS _ALL_ CLOSE;
101        
3                                                          The SAS System                          10:29 Wednesday, February 9, 2022

102        
103        QUIT; RUN;
104        &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Feb 2022 19:06:31 GMT</pubDate>
    <dc:creator>Esseny1</dc:creator>
    <dc:date>2022-02-09T19:06:31Z</dc:date>
    <item>
      <title>Iteration to change macro names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795268#M255062</link>
      <description>&lt;P&gt;I would need some advise as to how would I go about changing the two variable names under %LET ClusterGrp &amp;amp; %LET Finalf_ for various iterations. The first iteration would be run the entire code below with CLUSTER1 &amp;amp; Final1. Then change the name to CLUSTER2 &amp;amp; Final2 and do the whole process again till we reach CLUSTER10 &amp;amp; Final10. Would greatly appreciate any help on this topic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%LET ClusterGrp = CLUSTER1;
%LET Finalf_ = Final1;

/*2 place where input needs to be changed SIMULTANEOUSLY LINE16 &amp;amp; LINE17
FOLLOW THE GRID BELOW ON NAMING CONVENTIONS*/

/*FINAL1 GROUP WO 10 - CLUSTER1 */
/*FINAL2 GROUP WO 9  - CLUSTER2 */
/*FINAL3 GROUP WO 8  - CLUSTER3 */
/*FINAL4 GROUP WO 7  - CLUSTER4 */
/*FINAL5 GROUP WO 6  - CLUSTER5 */
/*FINAL6 GROUP WO 5  - CLUSTER6 */
/*FINAL7 GROUP WO 4  - CLUSTER7 */
/*FINAL8 GROUP WO 3  - CLUSTER8 */
/*FINAL9 GROUP WO 2  - CLUSTER9 */
/*FINAL10 GROUP WO 1  - CLUSTER10 */
/*&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;CHANGE HERE FOLLOW NM CONVEN ABOVE &amp;gt;&amp;gt;&amp;gt; */

/*FINAL OUTPUT FILE. THIS NEED TO BE CHANGED ONLY ONCE BEFORE "RUN 3" is EXECUTED*/
%LET FinalMean = DIAB001;

data WORK.inclusterdat_random9;
	set &amp;amp;ClusterGrp.;
run;

/*STANDARD CLUSTERING ALGORITHM*/
/*STEP 3*/
/*Measure Euclidean distance between data points*/
proc distance 
	data=WORK.inclusterdat_random9
	out=distancedat 
	method=Euclid;
	var interval(METRIC);
	id contract_id;
run;

/*STEP 4*/
/*cluster creation using Ward's minimum variance*/
proc cluster data=distancedat method=ward /*trim=1 k=3*/
	outtree=treedat noprint;
	id contract_id;
run;

/*STEP 5*/
/* replace NSTARS with numeric constant (# of star levels = 5)*/
proc tree data=treedat ncl=5 horizontal out=outclusterdat noprint;
	id contract_id;
run;

/*STEP 6*/
/*Join measure score to distinct cluster groupings*/
proc sql;
	CREATE TABLE WORK.JOIN AS 
		SELECT a.*,
			b.METRIC
		FROM work.outclusterdat a INNER JOIN WORK.inclusterdat_random9 b
			ON a.contract_id = b.contract_id
		order by CLUSTER DESC;

	/*STEP7*/
	/*Create upper bound threshold cutoff*/
	/*NOTE***Cluster output is naturally unordered so it needs to be reordered depending on measure (higher=better or lower=better)***/
	/*NAME OUT FILE TO NEW DATASET HERE */
	/*This step needs to by run multiple times to create the followig files - */
proc sql;
	CREATE TABLE &amp;amp;Finalf_. AS 
		SELECT DISTINCT cluster,
			MIN(METRIC) AS LOWER_BOUND
		FROM WORK.JOIN
			WHERE cluster BETWEEN 1 AND 5
				GROUP BY cluster
					ORDER BY LOWER_BOUND ASC;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 18:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795268#M255062</guid>
      <dc:creator>Esseny1</dc:creator>
      <dc:date>2022-02-09T18:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration to change macro names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795275#M255065</link>
      <description>&lt;UL&gt;
&lt;LI&gt;Wrap the code to be repeated into a macro&lt;/LI&gt;
&lt;LI&gt;Call the macro multiple times&amp;nbsp;
&lt;UL&gt;
&lt;LI&gt;Automate macro call using another macro or call execute to call it from a data step&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Here's some good references for these topics:&lt;/P&gt;
&lt;P&gt;UCLA introductory tutorial on macro variables and macros&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Tutorial on converting a working program to a macro&lt;BR /&gt;&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Examples of common macro usage&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wrap code in macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro analysis(clustergrp = , finalf_ , finalMean= );


data WORK.inclusterdat_random9;
	set &amp;amp;ClusterGrp.;
run;

/*STANDARD CLUSTERING ALGORITHM*/
/*STEP 3*/
/*Measure Euclidean distance between data points*/
proc distance 
	data=WORK.inclusterdat_random9
	out=distancedat 
	method=Euclid;
	var interval(METRIC);
	id contract_id;
run;

/*STEP 4*/
/*cluster creation using Ward's minimum variance*/
proc cluster data=distancedat method=ward /*trim=1 k=3*/
	outtree=treedat noprint;
	id contract_id;
run;

/*STEP 5*/
/* replace NSTARS with numeric constant (# of star levels = 5)*/
proc tree data=treedat ncl=5 horizontal out=outclusterdat noprint;
	id contract_id;
run;

/*STEP 6*/
/*Join measure score to distinct cluster groupings*/
proc sql;
	CREATE TABLE WORK.JOIN AS 
		SELECT a.*,
			b.METRIC
		FROM work.outclusterdat a INNER JOIN WORK.inclusterdat_random9 b
			ON a.contract_id = b.contract_id
		order by CLUSTER DESC;

	/*STEP7*/
	/*Create upper bound threshold cutoff*/
	/*NOTE***Cluster output is naturally unordered so it needs to be reordered depending on measure (higher=better or lower=better)***/
	/*NAME OUT FILE TO NEW DATASET HERE */
	/*This step needs to by run multiple times to create the followig files - */
proc sql;
	CREATE TABLE &amp;amp;Finalf_. AS 
		SELECT DISTINCT cluster,
			MIN(METRIC) AS LOWER_BOUND
		FROM WORK.JOIN
			WHERE cluster BETWEEN 1 AND 5
				GROUP BY cluster
					ORDER BY LOWER_BOUND ASC;
quit;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Call macro multiple times:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%analysis(ClusterGrp = Cluster1, Finalf_ = Final1, finalMean = DIAB001);
%analysis(ClusterGrp = Cluster2, Finalf_ = Final2, finalMean = DIAB001);
....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416171"&gt;@Esseny1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would need some advise as to how would I go about changing the two variable names under %LET ClusterGrp &amp;amp; %LET Finalf_ for various iterations. The first iteration would be run the entire code below with CLUSTER1 &amp;amp; Final1. Then change the name to CLUSTER2 &amp;amp; Final2 and do the whole process again till we reach CLUSTER10 &amp;amp; Final10. Would greatly appreciate any help on this topic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%LET ClusterGrp = CLUSTER1;
%LET Finalf_ = Final1;

/*2 place where input needs to be changed SIMULTANEOUSLY LINE16 &amp;amp; LINE17
FOLLOW THE GRID BELOW ON NAMING CONVENTIONS*/

/*FINAL1 GROUP WO 10 - CLUSTER1 */
/*FINAL2 GROUP WO 9  - CLUSTER2 */
/*FINAL3 GROUP WO 8  - CLUSTER3 */
/*FINAL4 GROUP WO 7  - CLUSTER4 */
/*FINAL5 GROUP WO 6  - CLUSTER5 */
/*FINAL6 GROUP WO 5  - CLUSTER6 */
/*FINAL7 GROUP WO 4  - CLUSTER7 */
/*FINAL8 GROUP WO 3  - CLUSTER8 */
/*FINAL9 GROUP WO 2  - CLUSTER9 */
/*FINAL10 GROUP WO 1  - CLUSTER10 */
/*&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;CHANGE HERE FOLLOW NM CONVEN ABOVE &amp;gt;&amp;gt;&amp;gt; */

/*FINAL OUTPUT FILE. THIS NEED TO BE CHANGED ONLY ONCE BEFORE "RUN 3" is EXECUTED*/
%LET FinalMean = DIAB001;

data WORK.inclusterdat_random9;
	set &amp;amp;ClusterGrp.;
run;

/*STANDARD CLUSTERING ALGORITHM*/
/*STEP 3*/
/*Measure Euclidean distance between data points*/
proc distance 
	data=WORK.inclusterdat_random9
	out=distancedat 
	method=Euclid;
	var interval(METRIC);
	id contract_id;
run;

/*STEP 4*/
/*cluster creation using Ward's minimum variance*/
proc cluster data=distancedat method=ward /*trim=1 k=3*/
	outtree=treedat noprint;
	id contract_id;
run;

/*STEP 5*/
/* replace NSTARS with numeric constant (# of star levels = 5)*/
proc tree data=treedat ncl=5 horizontal out=outclusterdat noprint;
	id contract_id;
run;

/*STEP 6*/
/*Join measure score to distinct cluster groupings*/
proc sql;
	CREATE TABLE WORK.JOIN AS 
		SELECT a.*,
			b.METRIC
		FROM work.outclusterdat a INNER JOIN WORK.inclusterdat_random9 b
			ON a.contract_id = b.contract_id
		order by CLUSTER DESC;

	/*STEP7*/
	/*Create upper bound threshold cutoff*/
	/*NOTE***Cluster output is naturally unordered so it needs to be reordered depending on measure (higher=better or lower=better)***/
	/*NAME OUT FILE TO NEW DATASET HERE */
	/*This step needs to by run multiple times to create the followig files - */
proc sql;
	CREATE TABLE &amp;amp;Finalf_. AS 
		SELECT DISTINCT cluster,
			MIN(METRIC) AS LOWER_BOUND
		FROM WORK.JOIN
			WHERE cluster BETWEEN 1 AND 5
				GROUP BY cluster
					ORDER BY LOWER_BOUND ASC;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 18:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795275#M255065</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-09T18:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration to change macro names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795295#M255070</link>
      <description>&lt;P&gt;Thanks Reeza ..&lt;/P&gt;&lt;P&gt;I am getting some error messaged on&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;25 GOPTIONS ACCESSIBLE;&lt;BR /&gt;ERROR: All positional parameters must precede keyword parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;84 %analysis(ClusterGrp = Cluster1, Finalf_ = Final1, finalMean = DIAB001);&lt;BR /&gt;_&lt;BR /&gt;180&lt;BR /&gt;WARNING: Apparent invocation of macro ANALYSIS not resolved.&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;WARNING: Apparent invocation of macro ANALYSIS not resolved.&lt;BR /&gt;85 %analysis(ClusterGrp = Cluster2, Finalf_ = Final2, finalMean = DIAB001);&lt;BR /&gt;_&lt;BR /&gt;180&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;1                                                          The SAS System                          10:29 Wednesday, February 9, 2022

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
4          %LET _CLIENTPROCESSFLOWNAME='Cluster - Optimization';
5          %LET _CLIENTPROJECTPATH='C:\Users\up0j1eb\Desktop\SNP Simulations\Cut_point_simulation_20220203_AY003.egp';
6          %LET _CLIENTPROJECTPATHHOST='HPZ155CG0502B2G';
7          %LET _CLIENTPROJECTNAME='Cut_point_simulation_20220203_AY003.egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HtmlBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome94/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&amp;amp;sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
ERROR: All positional parameters must precede keyword parameters.
26         %macro analysis(clustergrp = , finalf_ , finalMean= );
27         
28         data WORK.inclusterdat_random9;
29         	set &amp;amp;ClusterGrp.;
30         run;
31         
32         /*STANDARD CLUSTERING ALGORITHM*/
33         /*STEP 3*/
34         /*Measure Euclidean distance between data points*/
35         proc distance
36         	data=WORK.inclusterdat_random9
37         	out=distancedat
38         	method=Euclid;
39         	var interval(METRIC);
40         	id contract_id;
41         run;
42         
43         /*STEP 4*/
44         /*cluster creation using Ward's minimum variance*/
45         proc cluster data=distancedat method=ward /*trim=1 k=3*/
46         	outtree=treedat noprint;
47         	id contract_id;
48         run;
49         
50         /*STEP 5*/
51         /* replace NSTARS with numeric constant (# of star levels = 5)*/
52         proc tree data=treedat ncl=5 horizontal out=outclusterdat noprint;
53         	id contract_id;
54         run;
55         
56         /*STEP 6*/
2                                                          The SAS System                          10:29 Wednesday, February 9, 2022

57         /*Join measure score to distinct cluster groupings*/
58         proc sql;
59         	CREATE TABLE WORK.JOIN AS
60         		SELECT a.*,
61         			b.METRIC
62         		FROM work.outclusterdat a INNER JOIN WORK.inclusterdat_random9 b
63         			ON a.contract_id = b.contract_id
64         		order by CLUSTER DESC;
65         
66         	/*STEP7*/
67         	/*Create upper bound threshold cutoff*/
68         	/*NOTE***Cluster output is naturally unordered so it needs to be reordered depending on measure (higher=better or
68       ! lower=better)***/
69         	/*NAME OUT FILE TO NEW DATASET HERE */
70         	/*This step needs to by run multiple times to create the followig files - */
71         proc sql;
72         	CREATE TABLE &amp;amp;Finalf_. AS
73         		SELECT DISTINCT cluster,
74         			MIN(METRIC) AS LOWER_BOUND
75         		FROM WORK.JOIN
76         			WHERE cluster BETWEEN 1 AND 5
77         				GROUP BY cluster
78         					ORDER BY LOWER_BOUND ASC;
79         quit;
80         
81         %mend;
82         /*Call macro multiple times:*/
83         
84         %analysis(ClusterGrp = Cluster1, Finalf_ = Final1, finalMean = DIAB001);
           _
           180
WARNING: Apparent invocation of macro ANALYSIS not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
85         %analysis(ClusterGrp = Cluster2, Finalf_ = Final2, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

86         
87         
88         
89         
90         GOPTIONS NOACCESSIBLE;
91         %LET _CLIENTTASKLABEL=;
92         %LET _CLIENTPROCESSFLOWNAME=;
93         %LET _CLIENTPROJECTPATH=;
94         %LET _CLIENTPROJECTPATHHOST=;
95         %LET _CLIENTPROJECTNAME=;
96         %LET _SASPROGRAMFILE=;
97         %LET _SASPROGRAMFILEHOST=;
98         
99         ;*';*";*/;quit;run;
100        ODS _ALL_ CLOSE;
101        
3                                                          The SAS System                          10:29 Wednesday, February 9, 2022

102        
103        QUIT; RUN;
104        &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 19:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795295#M255070</guid>
      <dc:creator>Esseny1</dc:creator>
      <dc:date>2022-02-09T19:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration to change macro names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795310#M255078</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;I tried running the added code you noted above and getting the following errors now .. Can you advise as to what else be missing from the logic ? &lt;BR /&gt;Thanks - &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;1                                                          The SAS System                          10:29 Wednesday, February 9, 2022

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
4          %LET _CLIENTPROCESSFLOWNAME='Cluster - Optimization';
5          %LET _CLIENTPROJECTPATH='C:\Users\up0j1eb\Desktop\SNP Simulations\Cut_point_simulation_20220203_AY003.egp';
6          %LET _CLIENTPROJECTPATHHOST='HPZ155CG0502B2G';
7          %LET _CLIENTPROJECTNAME='Cut_point_simulation_20220203_AY003.egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HtmlBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome94/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&amp;amp;sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
ERROR: All positional parameters must precede keyword parameters.
26         %macro analysis(clustergrp = , finalf_ , finalMean= );
27         
28         data WORK.inclusterdat_random9;
29         	set &amp;amp;ClusterGrp.;
30         run;
31         
32         /*STANDARD CLUSTERING ALGORITHM*/
33         /*STEP 3*/
34         /*Measure Euclidean distance between data points*/
35         proc distance
36         	data=WORK.inclusterdat_random9
37         	out=distancedat
38         	method=Euclid;
39         	var interval(METRIC);
40         	id contract_id;
41         run;
42         
43         /*STEP 4*/
44         /*cluster creation using Ward's minimum variance*/
45         proc cluster data=distancedat method=ward /*trim=1 k=3*/
46         	outtree=treedat noprint;
47         	id contract_id;
48         run;
49         
50         /*STEP 5*/
51         /* replace NSTARS with numeric constant (# of star levels = 5)*/
52         proc tree data=treedat ncl=5 horizontal out=outclusterdat noprint;
53         	id contract_id;
54         run;
55         
56         /*STEP 6*/
2                                                          The SAS System                          10:29 Wednesday, February 9, 2022

57         /*Join measure score to distinct cluster groupings*/
58         proc sql;
59         	CREATE TABLE WORK.JOIN AS
60         		SELECT a.*,
61         			b.METRIC
62         		FROM work.outclusterdat a INNER JOIN WORK.inclusterdat_random9 b
63         			ON a.contract_id = b.contract_id
64         		order by CLUSTER DESC;
65         
66         	/*STEP7*/
67         	/*Create upper bound threshold cutoff*/
68         	/*NOTE***Cluster output is naturally unordered so it needs to be reordered depending on measure (higher=better or
68       ! lower=better)***/
69         	/*NAME OUT FILE TO NEW DATASET HERE */
70         	/*This step needs to by run multiple times to create the followig files - */
71         /*proc sql;*/
72         /*	CREATE TABLE &amp;amp;Finalf_. AS */
73         /*		SELECT DISTINCT cluster,*/
74         /*			MIN(METRIC) AS LOWER_BOUND*/
75         /*		FROM WORK.JOIN*/
76         /*			WHERE cluster BETWEEN 1 AND 5*/
77         /*				GROUP BY cluster*/
78         /*					ORDER BY LOWER_BOUND ASC;*/
79         quit;
80         
81         %mend;
82         
83         /*Call macro multiple times:*/
84         
85         %analysis(ClusterGrp = Cluster1, Finalf_ = Final1, finalMean = DIAB001);
           _
           180
WARNING: Apparent invocation of macro ANALYSIS not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
86         %analysis(ClusterGrp = Cluster2, Finalf_ = Final2, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
87         %analysis(ClusterGrp = Cluster3, Finalf_ = Final3, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
88         %analysis(ClusterGrp = Cluster4, Finalf_ = Final4, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
3                                                          The SAS System                          10:29 Wednesday, February 9, 2022

89         %analysis(ClusterGrp = Cluster5, Finalf_ = Final5, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
90         %analysis(ClusterGrp = Cluster6, Finalf_ = Final6, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
91         %analysis(ClusterGrp = Cluster7, Finalf_ = Final7, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
92         %analysis(ClusterGrp = Cluster8, Finalf_ = Final8, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
93         %analysis(ClusterGrp = Cluster9, Finalf_ = Final9, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

WARNING: Apparent invocation of macro ANALYSIS not resolved.
94         %analysis(ClusterGrp = Cluster10, Finalf_ = Final10, finalMean = DIAB001);
           _
           180

ERROR 180-322: Statement is not valid or it is used out of proper order.

95         
96         
97         
98         GOPTIONS NOACCESSIBLE;
99         %LET _CLIENTTASKLABEL=;
100        %LET _CLIENTPROCESSFLOWNAME=;
101        %LET _CLIENTPROJECTPATH=;
102        %LET _CLIENTPROJECTPATHHOST=;
103        %LET _CLIENTPROJECTNAME=;
104        %LET _SASPROGRAMFILE=;
105        %LET _SASPROGRAMFILEHOST=;
106        
107        ;*';*";*/;quit;run;
108        ODS _ALL_ CLOSE;
109        
110        
111        QUIT; RUN;
4                                                          The SAS System                          10:29 Wednesday, February 9, 2022

112        &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Feb 2022 20:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795310#M255078</guid>
      <dc:creator>Esseny1</dc:creator>
      <dc:date>2022-02-09T20:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Iteration to change macro names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795359#M255114</link>
      <description>Missed an equal sign after the finalf_ in the %macro line. &lt;BR /&gt;ERROR: All positional parameters must precede keyword parameters.&lt;BR /&gt;26         %macro analysis(clustergrp = , finalf_ , finalMean= );&lt;BR /&gt;&lt;BR /&gt;Add the equal sign so that finalf looks like finalMean/clusterGRP. &lt;BR /&gt;</description>
      <pubDate>Wed, 09 Feb 2022 21:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteration-to-change-macro-names/m-p/795359#M255114</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-09T21:48:33Z</dc:date>
    </item>
  </channel>
</rss>

