<?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: Evaluate a variable name to a table or to a variable class in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600055#M173354</link>
    <description>&lt;P&gt;So if the macro determines that it is the name of two tables, as well as the name of a variable in five other tables, will that work?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Oct 2019 13:16:57 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-10-29T13:16:57Z</dc:date>
    <item>
      <title>Evaluate a variable name to a table or to a variable class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600030#M173336</link>
      <description>&lt;P&gt;&lt;BR /&gt;Hi !,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to find a way in SAS to evaluate whether a certain varname is a variable or a table.&lt;/P&gt;&lt;P&gt;Ideas ?,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;let's asume I have the following examples:&lt;/P&gt;&lt;PRE&gt;data example1; 
Name = "Charles";
Surname = "Robinson";
run;

%let example2 = 201906 201704;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get that &amp;amp;example1 is a table somehow or check that &amp;amp;example2 is a variable ?&lt;/P&gt;&lt;P&gt;I will use that inside a macro as:&lt;/P&gt;&lt;P&gt;if (&amp;amp;example= table) {then X}&lt;/P&gt;&lt;P&gt;else if ((&amp;amp;example= variabe ){then Y );&lt;/P&gt;&lt;P&gt;else{Z}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advanced for your time and consideration,&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 12:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600030#M173336</guid>
      <dc:creator>carles</dc:creator>
      <dc:date>2019-10-29T12:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate a variable name to a table or to a variable class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600037#M173342</link>
      <description>&lt;P&gt;Example2 can't be either, as it is not a valid SAS name.&lt;/P&gt;
&lt;P&gt;If you have something that constitutes a valid SAS name, you can check it against dictionary.tables and dictionary.columns. Mind that this will only find occurrences in currently assigned libraries.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 12:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600037#M173342</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-29T12:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate a variable name to a table or to a variable class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600048#M173349</link>
      <description>SAS allows the same variable name to appear in many tables.  &lt;BR /&gt;&lt;BR /&gt;It also allows the same name to be both the name of a table and the name of a variable.&lt;BR /&gt;&lt;BR /&gt;These are common situations, not at all unusual.&lt;BR /&gt;&lt;BR /&gt;Will your plan still work?</description>
      <pubDate>Tue, 29 Oct 2019 12:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600048#M173349</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-10-29T12:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate a variable name to a table or to a variable class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600054#M173353</link>
      <description>&lt;P&gt;Yes, it is to pass it through a macro and just say whether it is a table or a variable.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 13:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600054#M173353</guid>
      <dc:creator>carles</dc:creator>
      <dc:date>2019-10-29T13:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate a variable name to a table or to a variable class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600055#M173354</link>
      <description>&lt;P&gt;So if the macro determines that it is the name of two tables, as well as the name of a variable in five other tables, will that work?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 13:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600055#M173354</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-10-29T13:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate a variable name to a table or to a variable class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600057#M173355</link>
      <description>Yes&lt;BR /&gt;</description>
      <pubDate>Tue, 29 Oct 2019 13:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600057#M173355</guid>
      <dc:creator>carles</dc:creator>
      <dc:date>2019-10-29T13:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate a variable name to a table or to a variable class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600058#M173357</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270253"&gt;@carles&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes, it is to pass it through a macro and just say whether it is a table or a variable.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It can be BOTH at the same time. See this example for library SASHELP:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select name label='Name', count(*) as count
from (
select distinct(upcase(name)) as name
from dictionary.columns
where libname = 'SASHELP'
union all
select distinct memname as name
from dictionary.tables
where libname = 'SASHELP'
)
group by name
having count &amp;gt; 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Name                                 count
------------------------------------------
CLASS                                    2
COMPANY                                  2
FEEDER                                   2
HOLIDAY                                  2
TABLE                                    2
THICK                                    2
&lt;/PRE&gt;
&lt;P&gt;All these appear both as variable and dataset name.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 13:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600058#M173357</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-29T13:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate a variable name to a table or to a variable class</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600081#M173364</link>
      <description>&lt;P&gt;So&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has already provided all the tools you would need to use.&amp;nbsp; Here is an overview.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your program will need to have issued LIBNAME statements are all the folders that need to be searched.&amp;nbsp; Otherwise, SAS has no way of knowing where to look to find tables and variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Query DICTIONARY.TABLES to find table names.&amp;nbsp; Query DICTIONARY.COLUMNS to find variable names.&amp;nbsp; In both cases, you need to modify the WHERE conditions in Kurt's examples to look for just the one name that you are hoping to categorize.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You still have to figure out how to proceed if the name is both a table name and a variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 14:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Evaluate-a-variable-name-to-a-table-or-to-a-variable-class/m-p/600081#M173364</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-10-29T14:43:30Z</dc:date>
    </item>
  </channel>
</rss>

