<?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 How to tell macro variable created or not inside PROC SQL?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981424#M379120</link>
    <description>&lt;P&gt;When using PROC SQL/Select column into: Macro_Variable from dataset[on condition], how to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tell whether the macro variable is created or not?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;CODE class=" language-sas"&gt;NOTE: No rows were selected."&amp;nbsp;indicates&amp;nbsp;no&amp;nbsp;creattion.&amp;nbsp;And&amp;nbsp;later&amp;nbsp;on,&amp;nbsp;my&amp;nbsp;code&amp;nbsp;complains&amp;nbsp;at&amp;nbsp;collecting&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;the&amp;nbsp;macro&amp;nbsp;variable&amp;nbsp;value.&amp;nbsp;I need&amp;nbsp;a&amp;nbsp;logic&amp;nbsp;to&amp;nbsp;tell&amp;nbsp;and&amp;nbsp;remove&amp;nbsp;the&amp;nbsp;complain.&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MPRINT(COLLDIF):   select ind into: ind_min_dif_off25 from _reg_temp_summ_ts_t where ind &amp;gt; 932 and zz500_t0_dif_14--0.96968&amp;gt;2.5*0.011659
having ind=min(ind);
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: No rows were selected.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 02 Jan 2026 05:38:12 GMT</pubDate>
    <dc:creator>hellohere</dc:creator>
    <dc:date>2026-01-02T05:38:12Z</dc:date>
    <item>
      <title>How to tell macro variable created or not inside PROC SQL?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981424#M379120</link>
      <description>&lt;P&gt;When using PROC SQL/Select column into: Macro_Variable from dataset[on condition], how to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tell whether the macro variable is created or not?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;CODE class=" language-sas"&gt;NOTE: No rows were selected."&amp;nbsp;indicates&amp;nbsp;no&amp;nbsp;creattion.&amp;nbsp;And&amp;nbsp;later&amp;nbsp;on,&amp;nbsp;my&amp;nbsp;code&amp;nbsp;complains&amp;nbsp;at&amp;nbsp;collecting&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;the&amp;nbsp;macro&amp;nbsp;variable&amp;nbsp;value.&amp;nbsp;I need&amp;nbsp;a&amp;nbsp;logic&amp;nbsp;to&amp;nbsp;tell&amp;nbsp;and&amp;nbsp;remove&amp;nbsp;the&amp;nbsp;complain.&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MPRINT(COLLDIF):   select ind into: ind_min_dif_off25 from _reg_temp_summ_ts_t where ind &amp;gt; 932 and zz500_t0_dif_14--0.96968&amp;gt;2.5*0.011659
having ind=min(ind);
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: No rows were selected.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Jan 2026 05:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981424#M379120</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2026-01-02T05:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to tell macro variable created or not inside PROC SQL?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981425#M379121</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409584"&gt;@hellohere&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would check the value of the automatic macro variable &lt;A href="https://documentation.sas.com/doc/en/sqlproc/1.0/p0xlnvl46zgqffn17piej7tewe7p.htm#p1cyzuadeotccqn1hwfdtmwejh2w" target="_blank" rel="noopener"&gt;SQLOBS&lt;/A&gt;, as this will work even if your macro variable&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ind_min_dif_off25&lt;/FONT&gt; exists (e.g., defined as global), but contains an outdated value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
proc sql noprint;
select age into :mvar trimmed from sashelp.class
where name='Bob';
quit;
%if &amp;amp;sqlobs=0 %then %do;
  %put %str(WAR)NING: No rows were selected, hence MVAR was not updated.;
  /* ... whatever else needs to be done ... */
%end;
%mend test;
%test&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jan 2026 09:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981425#M379121</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2026-01-02T09:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to tell macro variable created or not inside PROC SQL?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981426#M379122</link>
      <description>&lt;P&gt;Do NOT show us partial logs!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us the COMPLETE log for this PROC SQL — showing the PROC SQL statement in the log all the way down to the last note after the PROC SQL. Always show us the complete log for whatever PROC is causing the problem — always.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clearly, you are either accessing a data set which has zero observations, or you have a WHERE clause in PROC SQL that selects zero observations (or both). That's why you get the messages you are seeing.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jan 2026 10:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981426#M379122</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2026-01-02T10:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to tell macro variable created or not inside PROC SQL?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981427#M379123</link>
      <description>Two ways: use SQLOBS after the query, or set a default value before the query with a %LET.</description>
      <pubDate>Fri, 02 Jan 2026 10:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981427#M379123</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2026-01-02T10:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to tell macro variable created or not inside PROC SQL?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981428#M379124</link>
      <description>&lt;P&gt;Macro function %symexis() could do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
proc sql ;
select age into :mvar trimmed from sashelp.class
where name='Freelance';
quit;
%if %symexist(mvar) %then %do;
  %put  MVAR was updated.;
%end;
%else %put  MVAR was not created.;
%mend test;
%test&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Jan 2026 12:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-macro-variable-created-or-not-inside-PROC-SQL/m-p/981428#M379124</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-01-02T12:17:50Z</dc:date>
    </item>
  </channel>
</rss>

