<?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: Suggestion for new automatic macro variable SYSNVAR in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233094#M42538</link>
    <description>&lt;P&gt;Well, wasn't aware of these ones, I have always queried the metadata tables. &amp;nbsp;I suppose its because you should know the structure of your data, as knowing how many variables doesn't help much, I mean you can't really use that info. &amp;nbsp;However I like the idea, and it is part of the wider discussion on how to access the metadata of the system. &amp;nbsp;Personally I don't like the macro variable way of doing things. &amp;nbsp;In my way of thinking metadata should be accessible via a function, which can then be used directly in code explicitly on any dataset not just the last one, maybe something like:&lt;/P&gt;
&lt;P&gt;metadata(library=work,member=,property=[,where=]);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you could use it:&lt;/P&gt;
&lt;P&gt;number_of_observations=metadata(library=sashelp,member=cars,property=nobs);&lt;/P&gt;
&lt;P&gt;number_of_variables=metadata(library=sashelp,member=cars,property=nvar);&lt;/P&gt;
&lt;P&gt;Maybe you want to create an array for all col variables:&lt;/P&gt;
&lt;P&gt;array list_col{*} metadata(library=sashelp,member=cars,property=vars,where=%str(substr(varname,1,3)="COL"));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So a function that can return any of the metadata, not just obs, vars, but any property from table or columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Nov 2015 15:18:04 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-11-04T15:18:04Z</dc:date>
    <item>
      <title>Suggestion for new automatic macro variable SYSNVAR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233076#M42536</link>
      <description>&lt;P&gt;I am aware of the automatic macro variables SYSNOBS and SQLOBS, which tell me how many observations in a new table, but we do not seem to have one for number of variables. DICTIONARY.TABLES gives me NVAR, which tells me what I want, but I am surprised that we do not have a corresponding macro variable such as SYSNVAR.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2015 14:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233076#M42536</guid>
      <dc:creator>HuggyBob</dc:creator>
      <dc:date>2015-11-04T14:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Suggestion for new automatic macro variable SYSNVAR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233094#M42538</link>
      <description>&lt;P&gt;Well, wasn't aware of these ones, I have always queried the metadata tables. &amp;nbsp;I suppose its because you should know the structure of your data, as knowing how many variables doesn't help much, I mean you can't really use that info. &amp;nbsp;However I like the idea, and it is part of the wider discussion on how to access the metadata of the system. &amp;nbsp;Personally I don't like the macro variable way of doing things. &amp;nbsp;In my way of thinking metadata should be accessible via a function, which can then be used directly in code explicitly on any dataset not just the last one, maybe something like:&lt;/P&gt;
&lt;P&gt;metadata(library=work,member=,property=[,where=]);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you could use it:&lt;/P&gt;
&lt;P&gt;number_of_observations=metadata(library=sashelp,member=cars,property=nobs);&lt;/P&gt;
&lt;P&gt;number_of_variables=metadata(library=sashelp,member=cars,property=nvar);&lt;/P&gt;
&lt;P&gt;Maybe you want to create an array for all col variables:&lt;/P&gt;
&lt;P&gt;array list_col{*} metadata(library=sashelp,member=cars,property=vars,where=%str(substr(varname,1,3)="COL"));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So a function that can return any of the metadata, not just obs, vars, but any property from table or columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2015 15:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233094#M42538</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-04T15:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Suggestion for new automatic macro variable SYSNVAR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233124#M42551</link>
      <description>SAS has a semiformal method for making suggestions, you can post a new idea in the SAS ballotware section so others can vote on the idea. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas" target="_blank"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas&lt;/A&gt;</description>
      <pubDate>Wed, 04 Nov 2015 17:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233124#M42551</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-04T17:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Suggestion for new automatic macro variable SYSNVAR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233161#M42562</link>
      <description>&lt;P&gt;Something you are probably aware of, but maybe others are not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've always used sysfunc/qsysfunc with attrn or attrc functions to get to these metadata entries if I want to use functions or store things into macro variables. i.e., for the task at hand for number of variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let rc = %sysfunc(open(WORK.HAVE));
%let nvars = %sysfunc(attrn(&amp;amp;rc.,nvars));
%let rc = %sysfunc(close(WORK.HAVE));

%put &amp;amp;nvars.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The nice thing about these is they can be used in open code or in macros (in my experience).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other available attributes are viewable&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212040.htm" target="_self"&gt;here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 19:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233161#M42562</guid>
      <dc:creator>JoshB</dc:creator>
      <dc:date>2015-11-06T19:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Suggestion for new automatic macro variable SYSNVAR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233219#M42577</link>
      <description>&lt;P&gt;Yes, I quite agree. &amp;nbsp;The only thing I would say is that the need to do an close(open(function)) syntax is not ideal. &amp;nbsp;We should be able to pull metadata items using one simple function, which doesn't require opening/closing files, but just returns a query of the metdata tables.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 09:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233219#M42577</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-05T09:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Suggestion for new automatic macro variable SYSNVAR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233520#M42647</link>
      <description>Definitely true. Speaking of, I should probably add that to the end in case someone uses it and doesn't know to close.</description>
      <pubDate>Fri, 06 Nov 2015 19:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suggestion-for-new-automatic-macro-variable-SYSNVAR/m-p/233520#M42647</guid>
      <dc:creator>JoshB</dc:creator>
      <dc:date>2015-11-06T19:05:50Z</dc:date>
    </item>
  </channel>
</rss>

