<?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: Macro staying unresolved, neither any error nor any output. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-staying-unresolved-neither-any-error-nor-any-output/m-p/951906#M372086</link>
    <description>&lt;P&gt;You have not instructed SAS to execute the macro. You have only defined the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do this by this command&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%EXECUTE1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a side issue, defining a macro within another macro definition is not a good practice. Better to define the macros separately, consecutively.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro execute1;
/* code for macro execute1 goes here */
%mend execute;

%macro statemis1(region);
/* code for macro statemis1 goes here */
%mend statemis1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Nov 2024 15:42:32 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-11-26T15:42:32Z</dc:date>
    <item>
      <title>Macro staying unresolved, neither any error nor any output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-staying-unresolved-neither-any-error-nor-any-output/m-p/951905#M372085</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;I have been trying to execute this macro.&amp;nbsp;&lt;BR /&gt;The value of regions:&amp;nbsp;DL+UTT EAST GJ HR MH+ROM MP+CG PB+HP RJ SOUTH.&lt;/P&gt;
&lt;P&gt;I have defined the region if there is a gap in the value, then it will be considered as different region. So as for my input, there are 9 regions now. Which can change over time so I have kept the Regions and NUM_REGIONS as dynamic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* OPTIONS MPRINT MLOGIC SYMBOLGEN; */

%MACRO EXECUTE1;

%LET COUNT1=0;

PROC SQL;
SELECT COUNT(*) INTO :COUNT1
FROM CC_BASE_01NOV24;
QUIT;

%IF &amp;amp;COUNT1 &amp;gt; 0 %THEN %DO;
 

PROC SQL;
SELECT DISTINCT UPCASE(REGION) INTO :REGIONS SEPARATED BY ' '
FROM CC_BASE_01NOV24
WHERE REGION NE '#N/A';
SELECT COUNT(DISTINCT REGION) INTO :NUM_REGIONS
FROM CC_BASE_01NOV24
WHERE REGION NE '#N/A';
QUIT;

%PUT Unique Regions: &amp;amp;REGIONS;
%PUT Number of Regions: &amp;amp;NUM_REGIONS;




%MACRO STATEMIS1(REGION);
DATA CC_BASE_&amp;amp;BASE_DATE._&amp;amp;I.;
SET CC_BASE_01NOV24(WHERE=(UPCASE(STRIP(REGION))="&amp;amp;REGION."));
RUN;

%MEND STATEMIS1;


%DO I = 1 %TO &amp;amp;NUM_REGIONS;
%LET REGION = %SCAN(&amp;amp;REGIONS, &amp;amp;I, %STR( ));
%STATEMIS1(&amp;amp;REGION);
%END;
%END;
%ELSE %DO;
%PUT No records found in base dataset. Exiting macro.;
%END;
%MEND EXECUTE1;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;As&amp;nbsp;I&amp;nbsp;am&amp;nbsp;trying&amp;nbsp;to&amp;nbsp;execute&amp;nbsp;the&amp;nbsp;code,&amp;nbsp;it&amp;nbsp;runs&amp;nbsp;without&amp;nbsp;any&amp;nbsp;error&amp;nbsp;or&amp;nbsp;any&amp;nbsp;output&amp;nbsp;data&amp;nbsp;and&amp;nbsp;log&amp;nbsp;doesn't&amp;nbsp;show&amp;nbsp;anything&amp;nbsp;either.&lt;BR /&gt;I am attaching the log further:-&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;85   %MACRO EXECUTE1;
86   
87   %PUT EXECUTE1 Macro Started!;
88   %LET COUNT1=0;
89   
90   PROC SQL;
91   SELECT COUNT(*) INTO :COUNT1
92   FROM CC_BASE_01NOV24;
93   QUIT;
94   
95   %IF &amp;amp;COUNT1 &amp;gt; 0 %THEN %DO;
96   
97   
98   PROC SQL;
99   SELECT DISTINCT UPCASE(REGION) INTO :REGIONS SEPARATED BY ' '
100  FROM CC_BASE_01NOV24
101  /* WHERE REGION NE '#N/A'; */
102  SELECT COUNT(DISTINCT REGION) INTO :NUM_REGIONS
103  FROM CC_BASE_01NOV24
104  /* WHERE REGION NE '#N/A'; */
105  QUIT;
106  
107  %PUT Unique Regions: &amp;amp;REGIONS;
108  %PUT Number of Regions: &amp;amp;NUM_REGIONS;
109  
110  
111  
112  
113  %MACRO STATEMIS1(REGION);
114  %PUT &amp;amp;REGION.;
115  DATA CC_BASE_&amp;amp;BASE_DATE._&amp;amp;I.;
116  SET CC_BASE_01NOV24(WHERE=(UPCASE(STRIP(REGION))="&amp;amp;REGION."));
117  RUN;
118  
119  %MEND STATEMIS1;
120  
121  
122  %DO I = 1 %TO &amp;amp;NUM_REGIONS;
123  %LET REGION = %SCAN(&amp;amp;REGIONS, &amp;amp;I, %STR( ));
124  %STATEMIS1(&amp;amp;REGION);
125  %END;
126  %END;
127  %ELSE %DO;
128  %PUT No records found in base dataset. Exiting macro.;
129  %END;
130  %MEND EXECUTE1;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;I want this code to execute for all the unique regions in the set. But it isn't letting me.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;Can I please get help&amp;nbsp;as&amp;nbsp;I&amp;nbsp;have&amp;nbsp;checked&amp;nbsp;in&amp;nbsp;individual&amp;nbsp;steps&amp;nbsp;that,&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;COUNT1&amp;nbsp;has&amp;nbsp;15Lakh&amp;nbsp;values&amp;nbsp;in&amp;nbsp;it,&amp;nbsp;so&amp;nbsp;it&amp;nbsp;is&amp;nbsp;working&amp;nbsp;right.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;CC_BASE_01NOV24 has 9 unique regions so the loop should work 9 times for all the regions.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;What&amp;nbsp;is&amp;nbsp;it&amp;nbsp;that&amp;nbsp;I&amp;nbsp;am&amp;nbsp;doing&amp;nbsp;wrong&amp;nbsp;and&amp;nbsp;how&amp;nbsp;can&amp;nbsp;I&amp;nbsp;correct&amp;nbsp;it?&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;Thanks&amp;nbsp;You.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2024 13:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-staying-unresolved-neither-any-error-nor-any-output/m-p/951905#M372085</guid>
      <dc:creator>Discaboota</dc:creator>
      <dc:date>2024-11-26T13:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro staying unresolved, neither any error nor any output.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-staying-unresolved-neither-any-error-nor-any-output/m-p/951906#M372086</link>
      <description>&lt;P&gt;You have not instructed SAS to execute the macro. You have only defined the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do this by this command&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%EXECUTE1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a side issue, defining a macro within another macro definition is not a good practice. Better to define the macros separately, consecutively.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro execute1;
/* code for macro execute1 goes here */
%mend execute;

%macro statemis1(region);
/* code for macro statemis1 goes here */
%mend statemis1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2024 15:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-staying-unresolved-neither-any-error-nor-any-output/m-p/951906#M372086</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-11-26T15:42:32Z</dc:date>
    </item>
  </channel>
</rss>

