<?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: If Table Has a Column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509237#M136880</link>
    <description>&lt;P&gt;note you need to add seperated by ''&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select count(memname) into: CompctTableSumOutCount separated by '' from dictionary.columns&lt;BR /&gt; WHERE UPCASE(LIBNAME)="WORK" and memname = 'COMBINEDPCTTABLESUMMARYOUT';&lt;/P&gt;</description>
    <pubDate>Wed, 31 Oct 2018 18:02:39 GMT</pubDate>
    <dc:creator>DavidPhillips2</dc:creator>
    <dc:date>2018-10-31T18:02:39Z</dc:date>
    <item>
      <title>If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509218#M136864</link>
      <description>&lt;P&gt;I'm trying to check if a table&amp;nbsp;has a column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select count(*) into: CompctTableSumOutCount from CombinedpctTableSummaryOut;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Table WORK.COMBINEDPCTTABLESUMMARYOUT doesn't have any columns. PROC SQL requires each of its tables to have at least 1 &lt;BR /&gt; column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 17:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509218#M136864</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-10-31T17:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509220#M136866</link>
      <description>&lt;P&gt;Use dictionary.tables. It has a column containing number of columns. If you're looking for a specific column, use dictionary.columns.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 17:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509220#M136866</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-31T17:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509221#M136867</link>
      <description>&lt;P&gt;Use PROC SQL to query the DICTIONARY.TABLES table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    select nvar into :nvar from dictionary.tables where libname='WORK' and upcase(memname)='COMBINEDPCTTABLESUMMARYOUT';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 17:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509221#M136867</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-31T17:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509224#M136870</link>
      <description>&lt;P&gt;Here is a nice article about using dictionary tables and views:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi30/070-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/070-30.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 17:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509224#M136870</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2018-10-31T17:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509228#M136874</link>
      <description>&lt;P&gt;Try This :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(open(sashelp.class));&lt;BR /&gt;%let ncols=%sysfunc(attrn(&amp;amp;dsid,nvars));&lt;/P&gt;&lt;P&gt;%put &amp;amp;dsid &amp;amp;ncols;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro test;&lt;BR /&gt;%if &amp;amp;ncols &amp;gt; 0 %then %do;&lt;BR /&gt;proc sql ;&lt;BR /&gt;select count(*) into: CompctTableSumOutCount from sashelp.class;&lt;BR /&gt;quit;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%test&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 17:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509228#M136874</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-10-31T17:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509231#M136876</link>
      <description>&lt;P&gt;Why not just proc contents?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 17:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509231#M136876</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-31T17:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509234#M136878</link>
      <description>&lt;P&gt;Just to avoid an Error if there are no columns in the dataset.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 17:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509234#M136878</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-10-31T17:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509236#M136879</link>
      <description>&lt;P&gt;Good thinking.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 18:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509236#M136879</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-31T18:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509237#M136880</link>
      <description>&lt;P&gt;note you need to add seperated by ''&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select count(memname) into: CompctTableSumOutCount separated by '' from dictionary.columns&lt;BR /&gt; WHERE UPCASE(LIBNAME)="WORK" and memname = 'COMBINEDPCTTABLESUMMARYOUT';&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 18:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509237#M136880</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-10-31T18:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509238#M136881</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5059"&gt;@DavidPhillips2&lt;/a&gt;&amp;nbsp;why separated by&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to park the value of one var into one macro var???&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 18:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509238#M136881</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-31T18:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509276#M136893</link>
      <description>&lt;P&gt;You need separated by to remove the extra white space after the value.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 19:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509276#M136893</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-10-31T19:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509282#M136895</link>
      <description>&lt;P&gt;I'm running into a problem where the work table stays around beyond each run of the program.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 19:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509282#M136895</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-10-31T19:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509297#M136902</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5059"&gt;@DavidPhillips2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You need separated by to remove the extra white space after the value.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is what the TRIMMED keyword is for.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 19:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509297#M136902</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-31T19:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509495#M136978</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/**No variables and No observations**/
data class;
run;

%let dsid=%sysfunc(open(class));
%let ncols=%sysfunc(attrn(&amp;amp;dsid,any));
%let dsid=%sysfunc(close(&amp;amp;dsid));

%put &amp;amp;dsid &amp;amp;ncols;

/******No Observations****************/
data class;
 set sashelp.class;
 stop;
run;

%let dsid=%sysfunc(open(class));
%let ncols=%sysfunc(attrn(&amp;amp;dsid,any));
%let dsid=%sysfunc(close(&amp;amp;dsid));

%put &amp;amp;dsid &amp;amp;ncols;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Nov 2018 13:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509495#M136978</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-01T13:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: If Table Has a Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509510#M136984</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5059"&gt;@DavidPhillips2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You need separated by to remove the extra white space after the value.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In general you don't need this, for a specific use you might need to remove extra white space. But when I try this, I don't get white space after the expected zero in the macro variable.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 13:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Table-Has-a-Column/m-p/509510#M136984</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-01T13:59:48Z</dc:date>
    </item>
  </channel>
</rss>

