<?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: Juletip #10 Proc SQL and automatic macro variable in SAS Community Nordic</title>
    <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-10-Proc-SQL-and-automatic-macro-variable/m-p/424914#M156</link>
    <description>&lt;P&gt;Can you give some code examples?&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2018 14:01:05 GMT</pubDate>
    <dc:creator>andypandy_swe</dc:creator>
    <dc:date>2018-01-04T14:01:05Z</dc:date>
    <item>
      <title>Juletip #10 Proc SQL and automatic macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-10-Proc-SQL-and-automatic-macro-variable/m-p/318757#M18</link>
      <description>&lt;P&gt;The Juletip of today is simple but useful. When using PROC SQL it is often handy to export the number of observations of the resulting table into a macro variable. The good thing is that SAS does this automatically. The name of this macro variable is “sqlobs”:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at this small sample code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
create table extract as
select
*
from
sashelp.class
where sex='M'
;
quit;

%put NOTE: No. of males in sashelp.class: &amp;amp;sqlobs;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The resulting log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1
2    proc sql noprint;
3    create table extract as
4    select
5    *
6    from
7    sashelp.class
8    where sex='M'
9    ;
NOTE: Table WORK.EXTRACT created, with 10 rows and 5 columns.

10   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.06 seconds
      cpu time            0.00 seconds


11
12   %put NOTE: No. of males in sashelp.class: &amp;amp;sqlobs;
NOTE: No. of males in sashelp.class: 10
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Merry Christmas and a Happy New Year!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Niels-Kenneth Nielsen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 06:42:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-10-Proc-SQL-and-automatic-macro-variable/m-p/318757#M18</guid>
      <dc:creator>sdknkn</dc:creator>
      <dc:date>2016-12-14T06:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Juletip #10 Proc SQL and automatic macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-10-Proc-SQL-and-automatic-macro-variable/m-p/424902#M154</link>
      <description>&lt;P&gt;You need to be a bit careful though... If you use &amp;amp;sqlobs efter a proc sql that doesn't create a table and uses the noprint option you get &amp;amp;sqlobs=1 every time, as I discovered a few years&amp;nbsp;back when trying to find an error in my code... Note sure if this is a bug or a feature &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;create table extract as&lt;BR /&gt;select *&lt;BR /&gt;from sashelp.class&lt;BR /&gt;where sex='M';&lt;BR /&gt;quit;&lt;BR /&gt;%put &amp;amp;=sqlobs; /*prints SQLOBS=10*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select *&lt;BR /&gt;from sashelp.class&lt;BR /&gt;where sex='M';&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%put &amp;amp;=sqlobs; /*prints SQLOBS=10*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select *&lt;BR /&gt;from sashelp.class&lt;BR /&gt;where sex='M';&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%put &amp;amp;=sqlobs; /*prints SQLOBS=1*/&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 13:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-10-Proc-SQL-and-automatic-macro-variable/m-p/424902#M154</guid>
      <dc:creator>andypandy_swe</dc:creator>
      <dc:date>2018-01-04T13:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Juletip #10 Proc SQL and automatic macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-10-Proc-SQL-and-automatic-macro-variable/m-p/424908#M155</link>
      <description>&lt;P&gt;Well, the documentation doesn't&amp;nbsp;cover all situations on this issue, in fact I think it's a little missleading.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have just spent about 2h figuring this out - and to me it looks like the macrovar SQLOBS delivers value 1 if PROC SQL is able to fill in a value in a (new) macrovar. (eg finds a value from&amp;nbsp;a table), but a 0 (zero) if it is not able to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is a little confusing because SQLOBS also, in some situations, can take the value &amp;lt;blank&amp;gt; (that is: no value).&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 13:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-10-Proc-SQL-and-automatic-macro-variable/m-p/424908#M155</guid>
      <dc:creator>jmic_nyk</dc:creator>
      <dc:date>2018-01-04T13:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Juletip #10 Proc SQL and automatic macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-10-Proc-SQL-and-automatic-macro-variable/m-p/424914#M156</link>
      <description>&lt;P&gt;Can you give some code examples?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 14:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-10-Proc-SQL-and-automatic-macro-variable/m-p/424914#M156</guid>
      <dc:creator>andypandy_swe</dc:creator>
      <dc:date>2018-01-04T14:01:05Z</dc:date>
    </item>
  </channel>
</rss>

