<?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: How to print table name using proc fedsql in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938948#M45122</link>
    <description>&lt;P&gt;I suspect that PROC FEDSQL is treating "XXX" as a NAME instead of STRING LITERAL.&amp;nbsp; Just like PROC SQL would if you use the DQUOTE=ANSI option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using single quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let TABLE_NAME=Sales;
proc fedsql;
create table WANT as
  select %unquote(%bquote('&amp;amp;TABLE_NAME')) as Table_Name
       , CAST(COUNT(*) AS BIGINT) as Count
  from &amp;amp;table_name
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that trying to store an actual BIGINT value into a SAS numeric variable might cause trouble.&amp;nbsp; The maximum integer that SAS can store exactly is&amp;nbsp;9,007,199,254,740,992.&lt;/P&gt;
&lt;PRE&gt;1    data _null_;
2      maxint=constant('exactint');
3      put maxint= comma32.;
4    run;

maxint=9,007,199,254,740,992
&lt;/PRE&gt;</description>
    <pubDate>Mon, 12 Aug 2024 12:26:23 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-08-12T12:26:23Z</dc:date>
    <item>
      <title>How to print table name using proc fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938933#M45120</link>
      <description>&lt;P&gt;Hello Experts,&lt;BR /&gt;I am having a table which has more than 10billion records. By using PROC SQL, it prints the count in exponential value.&lt;BR /&gt;Due to that, I am using PROC FEDSQL to print the values. However, I want to print table name as well in my output. But, PROC FEDSQL considering hardcoded value as a column and searching it against the table and erroring by saying “Column not found”. Please help me to resolve this error.&lt;/P&gt;
&lt;P&gt;I have added the code below&lt;/P&gt;
&lt;P&gt;%LET TABLE_NAME=Sales;&lt;BR /&gt;PROC FEDSQL;&lt;BR /&gt;CREATE TABLE WANT AS&lt;BR /&gt;SELECT “&amp;amp;TABLE_NAME.” as Table_Name,&lt;BR /&gt;CAST(COUNT(*) AS BIGINT) as Count&lt;BR /&gt;From Sales;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;I am fetching count for many tables so I can’t hardcode table name directly. If I hardcode directly it’s working fine. But while resolving the hardcoded value in macro variable it’s considering it as a variable&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 07:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938933#M45120</guid>
      <dc:creator>_el_doredo</dc:creator>
      <dc:date>2024-08-12T07:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to print table name using proc fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938935#M45121</link>
      <description>&lt;PRE&gt;%let table_name = SALES; /* use uppercase! */

proc sql;
create table want as
  select
    memname as table_name,
    nobs as count format=15. /* increase format if needed */
  from dictionary.tables
  where libname = "WORK" and memname = "&amp;amp;table_name."
;
quit;&lt;/PRE&gt;
&lt;P&gt;Query the metadata instead of reading the whole dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS to do this for several datasets, create a dataset with libnames and memnames (all uppercase) and do a join with DICTIONARY.TABLES.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 09:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938935#M45121</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-08-12T09:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to print table name using proc fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938948#M45122</link>
      <description>&lt;P&gt;I suspect that PROC FEDSQL is treating "XXX" as a NAME instead of STRING LITERAL.&amp;nbsp; Just like PROC SQL would if you use the DQUOTE=ANSI option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using single quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let TABLE_NAME=Sales;
proc fedsql;
create table WANT as
  select %unquote(%bquote('&amp;amp;TABLE_NAME')) as Table_Name
       , CAST(COUNT(*) AS BIGINT) as Count
  from &amp;amp;table_name
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that trying to store an actual BIGINT value into a SAS numeric variable might cause trouble.&amp;nbsp; The maximum integer that SAS can store exactly is&amp;nbsp;9,007,199,254,740,992.&lt;/P&gt;
&lt;PRE&gt;1    data _null_;
2      maxint=constant('exactint');
3      put maxint= comma32.;
4    run;

maxint=9,007,199,254,740,992
&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Aug 2024 12:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938948#M45122</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-12T12:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to print table name using proc fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938961#M45123</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366820"&gt;@_el_doredo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To use macro variable in Proc FedSQL, you'll need to use&amp;nbsp;the SAS macro function %TSLIT.&lt;/P&gt;
&lt;P&gt;Check this on-line doc for reference&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0es4zov7qw8p3n1ttz8iw3dycgg.htm" target="_blank"&gt;SAS Help Center: Macro Variables&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 13:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938961#M45123</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2024-08-12T13:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to print table name using proc fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938964#M45124</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;Thanks for your response. All responses are working fine and another response I found is mentioning table name in single quotes also resolving this issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%LET TABLE_NAME=‘Sales’;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PROC FEDSQL;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CREATE TABLE WANT AS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SELECT “&amp;amp;TABLE_NAME.” as Table_Name,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CAST(COUNT(*) AS BIGINT) as Count&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;From Sales;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;QUIT;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 13:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-print-table-name-using-proc-fedsql/m-p/938964#M45124</guid>
      <dc:creator>_el_doredo</dc:creator>
      <dc:date>2024-08-12T13:37:38Z</dc:date>
    </item>
  </channel>
</rss>

