<?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 determine if there is no column within a dataset in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384283#M11597</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code is like following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro noshow_fcst;
OPTIONS NOTES SOURCE SOURCE2 MPRINT MLOGIC MERROR SYMBOLGEN;

data _null_;
 set PO_LOC end=last;
 if last then call symput('nfiles',_n_);
run;

%do i=1 %to &amp;amp;nfiles;
	%put i =;

	data _null_;
		set PO_LOC;

		if &amp;amp;i=_n_ then
			call symput('LOC_ID',LOC_ID);
	run;

	%Let Lead_Time = 0;
	
                /* HIST5_&amp;amp;LOC_ID IS obtained from Teradata database */

		/* Transfer pure Noshow and Cancellation from 'arrival date' &amp;amp; 'length of stay' level to 'stay date' */
		DATA HIST5_1_&amp;amp;LOC_ID;
			SET HIST5_&amp;amp;LOC_ID;
				Cancellation_Lead = Arrival_Date - Cancel_Date; 
					if Cancellation_Lead &amp;gt; 30 then Cancellation_Lead = 30;
					If Cancellation_Lead &amp;lt; 0 then Cancellation_Lead = 0;
				FORMAT Stay_Date yymmdd10.;
			do k=1 to length_of_stay;
				Stay_Date = Arrival_Date - 1 + k;
			output;
			end;
			drop k length_of_stay;
		run;

				/* Filter the data as we count 'No-show' for 1 night and Cancellation for Lead Time N */
		Data HIST5_2_&amp;amp;LOC_ID;
			Set HIST5_1_&amp;amp;LOC_ID;
			If Cancellations &amp;gt; 0 and Cancellation_Lead &amp;gt; &amp;amp;Lead_Time then delete;
			If Stay_Date &amp;gt; Arrival_Date and Noshows &amp;gt; 0 then delete;
		Run;
	

		/* Actual Noshow and Cancellation data by Stay Date (Month and Day of Week) level */
		Proc Sql;
			Create Table HIST5_3_&amp;amp;LOC_ID as select distinct
				Operating_Div_Cd,
				Chain_Cd,
				Loc_Id,
				Stay_Date,
				Month(Stay_Date) as Mon,
				Weekday(Stay_Date) as Dow,
				Prod_Class_Id,
				sum(Cancellations+Noshows) as Cancel_Noshow
			from HIST5_2_&amp;amp;LOC_ID
			group by 1, 2, 3, 4, 5, 6, 7
			order by 1, 2, 3, 7, 4;
		Quit;

		/* Forecasting Approach: Poisson Regression, omitting impact of Special Event */
		/* This part could obatin data for Noshow + Cancellation on some Lead Time */
		proc genmod data=HIST5_3_&amp;amp;LOC_ID;
			class Mon Dow;
			by Operating_Div_cd chain_cd loc_id prod_class_id;
			model Cancel_Noshow = Mon Dow/ dist=poisson
			link=log scale=pearson;
			output out=HIST_5_6_Pos_&amp;amp;LOC_ID p=Noshow_Cancel_Pred_Pos;
			where Stay_Date between &amp;amp;START1 and &amp;amp;END1;
		run;
		ods exclude all; 

		/* Check if HIST_5_6_Pos_&amp;amp;LOC_ID has any columns or not */
		Proc Sql noprint;
			Select count(distinct name) into: does_column_exist
			from sashelp.vcolumn where lowcase(name) = "noshow_cancel_pred_pos" and lowcase(memname) = "hist_5_6_pos_&amp;amp;loc_id";
		Quit;

		%if &amp;amp;does_column_exist &amp;gt; 0 %then %do;

		/* Gather output data by Month and day of week level for Noshow + Cancellation */
		Proc Sql;
			Create Table Noshowfcst_&amp;amp;LOC_ID as select distinct 
				Operating_Div_Cd,
				Chain_Cd,
				Loc_Id,
				Prod_Class_Id,
				Mon,
				Dow,
				Case 
					When Weekday(Stay_Date) in (1,2,3,4,5) then 'WD'
					Else 'WE'
				End	as DY_TYP,
				avg(Noshow_Cancel_Pred_Pos) as Noshow_Fcst
			from HIST_5_6_Pos_&amp;amp;LOC_ID
			group by 1, 2, 3, 4, 5, 6, 7;
		Quit;
		
		%end;
			%else %do;
			%end;


				
%end;

%mend;
	/* The first macro ends for No-show Forecasting */

%noshow_fcst;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part of Log Information for&amp;nbsp;&lt;SPAN&gt;HIST_5_6_POS_&amp;amp;LOC_ID:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.HIST_5_6_POS_AADAL has 912 observations and 9 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: &amp;nbsp;Macro variable LOC_ID resolves to AADAL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MPRINT(NOSHOW_FCST): Select count(distinct name) into: does_column_exist from sashelp.vcolumn where lowcase(name) =&lt;BR /&gt;"noshow_cancel_pred_pos" and lowcase(memname) = "hist_5_6_pos_AADAL";&lt;BR /&gt;MPRINT(NOSHOW_FCST): Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable DOES_COLUMN_EXIST resolves to 0&lt;BR /&gt;MLOGIC(NOSHOW_FCST): %IF condition &amp;amp;does_column_exist &amp;gt; 0 is FALSE&lt;BR /&gt;MLOGIC(NOSHOW_FCST): %DO loop index variable I is now 2; loop will iterate again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part of the data for 'hist_5_6_pos_&amp;amp;loc_id' :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Question.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14236iBDB01B2B598AC04A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Question.PNG" alt="Question.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you! And for this example, 'Noshowfcst_&amp;amp;LOC_ID' cannot be obtained even if 'hist_5_6_pos_&amp;amp;LOC_ID' exists.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2017 14:32:37 GMT</pubDate>
    <dc:creator>Crubal</dc:creator>
    <dc:date>2017-07-31T14:32:37Z</dc:date>
    <item>
      <title>How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383711#M11569</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question within my sas macro function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some exceptional cases that Table A may not have any columns. And I would like the process going if it has columns, and stops when it does not have. How could I make it happen?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 14:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383711#M11569</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-07-28T14:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383722#M11570</link>
      <description>&lt;P&gt;Check the metadata:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vcolumn (where=(libname="&amp;lt;your lib&amp;gt;" and memname="&amp;lt;your dataset&amp;gt;"));
  if _n_=1 then call execute('%macro CodeToExecute;');
run;&lt;/PRE&gt;
&lt;P&gt;This will only call the CodeToExecute macro if in &amp;lt;your lib&amp;gt;.&amp;lt;your dataset&amp;gt; (all in capitals in this case) contains 1 or more columns.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 14:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383722#M11570</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-28T14:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383751#M11571</link>
      <description>&lt;P&gt;Thanks for your reply&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I didnot explain clearly. In my case, this part is within a macro process. For example, my pseudo code looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%Macro ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obtain Table A from database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check if Table A has columns or not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Run later process.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%Mend;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I realize ( Check if Table A has columns or not)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 15:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383751#M11571</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-07-28T15:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383757#M11572</link>
      <description>&lt;P&gt;inside your macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run some code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;check to see if the column exists using the code provided by RW9, where the additional processing is what he calls CodeToExecute (which will execute only if the column exists)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;end of macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;execute macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ALTERNATIVE&lt;/P&gt;
&lt;P&gt;Create a macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run some code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;check to see if the column exists&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
    select count(distinct name) into :does_column_exist
   from sashelp.vcolumn where name='desired_column_name'
        and lib='your_library' and memname='your_data_set_name';
quit;
%if &amp;amp;does_column_exist&amp;gt;0 %then %do;&lt;/PRE&gt;
&lt;P&gt;Note, capitalization is important in name='desired_column_name', so this can be avoided by&lt;/P&gt;
&lt;P&gt;lowcase(name)='desired_column_name' in all lower case&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rest of code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Execute macro&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 15:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383757#M11572</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-28T15:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383771#M11573</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Check the metadata:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vcolumn (where=(libname="&amp;lt;your lib&amp;gt;" and memname="&amp;lt;your dataset&amp;gt;"));
  if _n_=1 then call execute('%macro CodeToExecute;');
run;&lt;/PRE&gt;
&lt;P&gt;This will only call the CodeToExecute macro if in &amp;lt;your lib&amp;gt;.&amp;lt;your dataset&amp;gt; (all in capitals in this case) contains 1 or more columns.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Shouldn't that say&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if _n_=1 then call execute('%CodeToExecute;');
&lt;/PRE&gt;
&lt;P&gt;where the macro CodeToExecute has already been defined?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 15:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383771#M11573</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-28T15:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383777#M11574</link>
      <description>&lt;P&gt;Yes, indeed. &amp;nbsp;Problem with writing code your not running. &amp;nbsp; Could of course be any valid SAS code, doesn't need to be a macro call.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 15:51:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383777#M11574</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-28T15:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383779#M11575</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; It works for me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 15:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383779#M11575</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-07-28T15:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383901#M11582</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;I tried as you suggested:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set sashelp.vcolumn (where=(libname = "&amp;lt;WORK&amp;gt;" and memname = "&amp;lt;Table A&amp;gt;"));&lt;BR /&gt;%if _n_ = 1 %then %do;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Proc Sql;&lt;BR /&gt;Create Table&amp;nbsp;Table B as select distinct&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;from ...&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, even though Table A has columns, the log file shows _n_ = 1 is false, and cannot do later sql procedure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How could I modify it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 19:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383901#M11582</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-07-28T19:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383904#M11583</link>
      <description>&lt;P&gt;Show us your actual code (at least the relevant parts)&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 19:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383904#M11583</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-28T19:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383907#M11584</link>
      <description>&lt;P&gt;Okay thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following obtains Table A_&amp;amp;LOC_ID. &amp;nbsp;Where &amp;amp;LOC_ID differs by location.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=A0_&amp;amp;LOC_ID;
class Mon Dow;
by Operating_Div_cd chain_cd loc_id prod_class_id;
model Cancel_Noshow = Mon Dow/ dist=poisson
link=log scale=pearson;
output out=A_&amp;amp;LOC_ID p=Noshow_Cancel_Pred_Pos;
where Stay_Date between &amp;amp;START1 and &amp;amp;END1;
run;
ods exclude all;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following checks if table A_&amp;amp;LOC_ID has any columns or not. And continue the process to get B_&amp;amp;LOC_ID.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Check if table A_&amp;amp;LOC_ID has any columns or not */

data _null_;
set sashelp.vcolumn (where=(libname = "&amp;lt;WORK&amp;gt;" and memname = "&amp;lt;HIST_5_6_Pos_&amp;amp;LOC_ID&amp;gt;"));
%if _n_ = 1 %then %do;

/* Continue the process when _n_ = 1&amp;nbsp;*/
Proc Sql;
Create Table B_&amp;amp;LOC_ID as select distinct 
Operating_Div_Cd,
Chain_Cd,
Loc_Id,
Prod_Class_Id,
Mon,
Dow,
Case 
When Weekday(Stay_Date) in (1,2,3,4,5) then 'WD'
Else 'WE'
End as DY_TYP,
avg(Noshow_Cancel_Pred_Pos) as Noshow_Fcst
from A_&amp;amp;LOC_ID
group by 1, 2, 3, 4, 5, 6, 7;
Quit;

%end;

Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 20:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383907#M11584</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-07-28T20:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383944#M11586</link>
      <description>&lt;P&gt;You have fallen into two common misconceptions:&lt;/P&gt;
&lt;P&gt;1) What macro language is compared to Base SAS. &amp;nbsp;Macro language, all those % and &amp;amp;'s, is a pre-processor, i.e. a limited scope text generation tool. &amp;nbsp;If scans the text you present and using some simple logic expands the text out. &amp;nbsp;This full text is then passed on to the Base SAS compiler which compiles and executes the script. &amp;nbsp;You are using _n_ which is an automatic &lt;STRONG&gt;datastep&amp;nbsp;&lt;/STRONG&gt;variable&amp;nbsp;in macro processing, which is not going to work. &amp;nbsp;You would need to call execute, or put a value into a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Having the thinking that you need to split data out and then loop over that data. &amp;nbsp;You can simplify your code so much, and save yourself a lot of headaches is dropping this whole thinking. &amp;nbsp;As an example, you are looping over the data blocking out certain items and then running some models. &amp;nbsp;Another way of looking at it would be to add into the data another variable, a categorising variable, which holds this blocking information, then include that in the by group processing. &amp;nbsp;That way you don't loop, but leave the procedure to handle all that. &amp;nbsp;If you can provide some simple test data, I can show you, but for example, I could take sashelp.class and do a loop over that data based on gender, i.e. it would be %do i=1 % to 2;..., alternatively I could just add gender into the by group.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 21:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383944#M11586</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-28T21:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383957#M11587</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50019"&gt;@Crubal&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Okay thanks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following obtains Table A_&amp;amp;LOC_ID. &amp;nbsp;Where &amp;amp;LOC_ID differs by location.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=A0_&amp;amp;LOC_ID;
class Mon Dow;
by Operating_Div_cd chain_cd loc_id prod_class_id;
model Cancel_Noshow = Mon Dow/ dist=poisson
link=log scale=pearson;
output out=A_&amp;amp;LOC_ID p=Noshow_Cancel_Pred_Pos;
where Stay_Date between &amp;amp;START1 and &amp;amp;END1;
run;
ods exclude all;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following checks if table A_&amp;amp;LOC_ID has any columns or not. And continue the process to get B_&amp;amp;LOC_ID.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Check if table A_&amp;amp;LOC_ID has any columns or not */

data _null_;
set sashelp.vcolumn (where=(libname = "&amp;lt;WORK&amp;gt;" and memname = "&amp;lt;HIST_5_6_Pos_&amp;amp;LOC_ID&amp;gt;"));
%if _n_ = 1 %then %do;

/* Continue the process when _n_ = 1&amp;nbsp;*/
Proc Sql;
Create Table B_&amp;amp;LOC_ID as select distinct 
Operating_Div_Cd,
Chain_Cd,
Loc_Id,
Prod_Class_Id,
Mon,
Dow,
Case 
When Weekday(Stay_Date) in (1,2,3,4,5) then 'WD'
Else 'WE'
End as DY_TYP,
avg(Noshow_Cancel_Pred_Pos) as Noshow_Fcst
from A_&amp;amp;LOC_ID
group by 1, 2, 3, 4, 5, 6, 7;
Quit;

%end;

Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's the code I suggested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
    select count(distinct name) into :does_column_exist
   from sashelp.vcolumn where lowcase(name)='desired_column_name'
        and lowcase(lib)='your_library' and lowcase(memname)='your_data_set_name';
quit;
%if &amp;amp;does_column_exist&amp;gt;0 %then %do;&lt;/PRE&gt;
&lt;P&gt;You haven't really done anything like this. Please note that where I have typed desired_column_name you should type the actual name of the variable in lower case, etc. etc. etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also remember there needs to be an %end; statement somewhere below&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 23:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/383957#M11587</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-28T23:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384262#M11593</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply, and I tried yours in the very beginning, but result is same. Could you please let me know anything wrong with the following code? Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;		proc genmod data=A0_&amp;amp;LOC_ID;
			class Mon Dow;
			by Operating_Div_cd chain_cd loc_id prod_class_id;
			model Cancel_Noshow = Mon Dow/ dist=poisson
			link=log scale=pearson;
			output out=A_&amp;amp;LOC_ID p=Noshow_Cancel_Pred_Pos;
			where Stay_Date between &amp;amp;START1 and &amp;amp;END1;
		run;
		ods exclude all; &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Check if A_&amp;amp;LOC_ID has any columns or not */
Proc Sql noprint;
   Select count(distinct name) into: does_column_exist
      from sashelp.vcolumn where lowcase(name) = 'noshow_cancel_pred_pos' and lowcase(memname) = 'a_&amp;amp;loc_id';
Quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;       /* Conduct the following part according to the condition */&lt;BR /&gt;	%if &amp;amp;does_column_exist &amp;gt; 0 %then %do;

		/* Gather output data by Month and day of week level for Noshow + Cancellation */
		Proc Sql;
			Create Table B_&amp;amp;LOC_ID as select distinct 
				Operating_Div_Cd,
				Chain_Cd,
				Loc_Id,
				Prod_Class_Id,
				Mon,
				Dow,
				Case 
					When Weekday(Stay_Date) in (1,2,3,4,5) then 'WD'
					Else 'WE'
				End	as DY_TYP,
				avg(Noshow_Cancel_Pred_Pos) as Noshow_Fcst
			from A_&amp;amp;LOC_ID
			group by 1, 2, 3, 4, 5, 6, 7;
		Quit;
		
		%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 13:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384262#M11593</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-07-31T13:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384264#M11594</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50019"&gt;@Crubal&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your reply, and I tried yours in the very beginning, but result is same. Could you please let me know anything wrong with the following code? Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Check if A_&amp;amp;LOC_ID has any columns or not */
Proc Sql noprint;
   Select count(distinct name) into: does_column_exist
      from sashelp.vcolumn where lowcase(name) = 'noshow_cancel_pred_pos' and lowcase(memname) = 'a_&amp;amp;loc_id';
Quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you have a macro variable, you can't put it inside single quotes. You must put it inside double quotes.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 13:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384264#M11594</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-31T13:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384270#M11595</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it like the following? I tried but returns same result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;		Proc Sql noprint;
			Select count(distinct name) into: does_column_exist
			from sashelp.vcolumn where lowcase(name) = "noshow_cancel_pred_pos" and lowcase(memname) = "hist_5_6_pos_&amp;amp;loc_id";
		Quit;

		%if &amp;amp;does_column_exist &amp;gt; 0 %then %do;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 13:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384270#M11595</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-07-31T13:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384272#M11596</link>
      <description>&lt;P&gt;So let's stop right here and discuss some basic necessities of forum usage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can't say things like "it didn't work", or in your case "but returns same result". We have no idea what you mean. We don't know why it doesn't work or returns the same result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have to tell us what didn't work, and the best way to do that is to show us the relevant parts of your SASLOG. You also have to show us your SAS code (which you did), and in some cases you have to show us your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 13:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384272#M11596</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-31T13:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384283#M11597</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code is like following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro noshow_fcst;
OPTIONS NOTES SOURCE SOURCE2 MPRINT MLOGIC MERROR SYMBOLGEN;

data _null_;
 set PO_LOC end=last;
 if last then call symput('nfiles',_n_);
run;

%do i=1 %to &amp;amp;nfiles;
	%put i =;

	data _null_;
		set PO_LOC;

		if &amp;amp;i=_n_ then
			call symput('LOC_ID',LOC_ID);
	run;

	%Let Lead_Time = 0;
	
                /* HIST5_&amp;amp;LOC_ID IS obtained from Teradata database */

		/* Transfer pure Noshow and Cancellation from 'arrival date' &amp;amp; 'length of stay' level to 'stay date' */
		DATA HIST5_1_&amp;amp;LOC_ID;
			SET HIST5_&amp;amp;LOC_ID;
				Cancellation_Lead = Arrival_Date - Cancel_Date; 
					if Cancellation_Lead &amp;gt; 30 then Cancellation_Lead = 30;
					If Cancellation_Lead &amp;lt; 0 then Cancellation_Lead = 0;
				FORMAT Stay_Date yymmdd10.;
			do k=1 to length_of_stay;
				Stay_Date = Arrival_Date - 1 + k;
			output;
			end;
			drop k length_of_stay;
		run;

				/* Filter the data as we count 'No-show' for 1 night and Cancellation for Lead Time N */
		Data HIST5_2_&amp;amp;LOC_ID;
			Set HIST5_1_&amp;amp;LOC_ID;
			If Cancellations &amp;gt; 0 and Cancellation_Lead &amp;gt; &amp;amp;Lead_Time then delete;
			If Stay_Date &amp;gt; Arrival_Date and Noshows &amp;gt; 0 then delete;
		Run;
	

		/* Actual Noshow and Cancellation data by Stay Date (Month and Day of Week) level */
		Proc Sql;
			Create Table HIST5_3_&amp;amp;LOC_ID as select distinct
				Operating_Div_Cd,
				Chain_Cd,
				Loc_Id,
				Stay_Date,
				Month(Stay_Date) as Mon,
				Weekday(Stay_Date) as Dow,
				Prod_Class_Id,
				sum(Cancellations+Noshows) as Cancel_Noshow
			from HIST5_2_&amp;amp;LOC_ID
			group by 1, 2, 3, 4, 5, 6, 7
			order by 1, 2, 3, 7, 4;
		Quit;

		/* Forecasting Approach: Poisson Regression, omitting impact of Special Event */
		/* This part could obatin data for Noshow + Cancellation on some Lead Time */
		proc genmod data=HIST5_3_&amp;amp;LOC_ID;
			class Mon Dow;
			by Operating_Div_cd chain_cd loc_id prod_class_id;
			model Cancel_Noshow = Mon Dow/ dist=poisson
			link=log scale=pearson;
			output out=HIST_5_6_Pos_&amp;amp;LOC_ID p=Noshow_Cancel_Pred_Pos;
			where Stay_Date between &amp;amp;START1 and &amp;amp;END1;
		run;
		ods exclude all; 

		/* Check if HIST_5_6_Pos_&amp;amp;LOC_ID has any columns or not */
		Proc Sql noprint;
			Select count(distinct name) into: does_column_exist
			from sashelp.vcolumn where lowcase(name) = "noshow_cancel_pred_pos" and lowcase(memname) = "hist_5_6_pos_&amp;amp;loc_id";
		Quit;

		%if &amp;amp;does_column_exist &amp;gt; 0 %then %do;

		/* Gather output data by Month and day of week level for Noshow + Cancellation */
		Proc Sql;
			Create Table Noshowfcst_&amp;amp;LOC_ID as select distinct 
				Operating_Div_Cd,
				Chain_Cd,
				Loc_Id,
				Prod_Class_Id,
				Mon,
				Dow,
				Case 
					When Weekday(Stay_Date) in (1,2,3,4,5) then 'WD'
					Else 'WE'
				End	as DY_TYP,
				avg(Noshow_Cancel_Pred_Pos) as Noshow_Fcst
			from HIST_5_6_Pos_&amp;amp;LOC_ID
			group by 1, 2, 3, 4, 5, 6, 7;
		Quit;
		
		%end;
			%else %do;
			%end;


				
%end;

%mend;
	/* The first macro ends for No-show Forecasting */

%noshow_fcst;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part of Log Information for&amp;nbsp;&lt;SPAN&gt;HIST_5_6_POS_&amp;amp;LOC_ID:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.HIST_5_6_POS_AADAL has 912 observations and 9 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: &amp;nbsp;Macro variable LOC_ID resolves to AADAL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MPRINT(NOSHOW_FCST): Select count(distinct name) into: does_column_exist from sashelp.vcolumn where lowcase(name) =&lt;BR /&gt;"noshow_cancel_pred_pos" and lowcase(memname) = "hist_5_6_pos_AADAL";&lt;BR /&gt;MPRINT(NOSHOW_FCST): Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable DOES_COLUMN_EXIST resolves to 0&lt;BR /&gt;MLOGIC(NOSHOW_FCST): %IF condition &amp;amp;does_column_exist &amp;gt; 0 is FALSE&lt;BR /&gt;MLOGIC(NOSHOW_FCST): %DO loop index variable I is now 2; loop will iterate again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part of the data for 'hist_5_6_pos_&amp;amp;loc_id' :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Question.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14236iBDB01B2B598AC04A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Question.PNG" alt="Question.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you! And for this example, 'Noshowfcst_&amp;amp;LOC_ID' cannot be obtained even if 'hist_5_6_pos_&amp;amp;LOC_ID' exists.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 14:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384283#M11597</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-07-31T14:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384285#M11598</link>
      <description>&lt;P&gt;We need to see the SASLOG with the following options enabled&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OPTIONS SOURCE MPRINT MPRINTNEST NOSYMBOLGEN NOMLOGIC;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And also please explain in WORDS what is not working. You haven't done that either. We need both ... the word explanation and the SASLOG.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:01:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384285#M11598</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-31T15:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384320#M11599</link>
      <description>&lt;P&gt;Part of SASLOG:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MLOGIC(NOSHOW_FCST): Beginning execution.&lt;BR /&gt;MPRINT(NOSHOW_FCST): OPTIONS NOTES SOURCE SOURCE2 MPRINT MLOGIC MERROR SYMBOLGEN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think it is enabled.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Check if Hist_5_6_&amp;amp;LOC_ID exists':&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc Sql noprint;&lt;BR /&gt;Select count(distinct name) into: does_column_exist&lt;BR /&gt;from sashelp.vcolumn where lowcase(name) = "noshow_cancel_pred_pos" and lowcase(memname) = "hist_5_6_pos_&amp;amp;loc_id";&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log file for the part 'Check if Hist_5_6_&amp;amp;LOC_ID exists':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable DOES_COLUMN_EXIST resolves to 0&lt;BR /&gt;MLOGIC(NOSHOW_FCST): %IF condition &amp;amp;does_column_exist &amp;gt; 0 is FALSE&lt;BR /&gt;MLOGIC(NOSHOW_FCST): %DO loop index variable I is now 2; loop will iterate again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, dataset 'Hist_5_6_&amp;amp;LOC_ID' exists, as logfile mentions:&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.HIST_5_6_POS_AADAL has 912 observations and 9 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I would assume&amp;nbsp;&lt;SPAN&gt;%IF condition &amp;amp;does_column_exist &amp;gt; 0&amp;nbsp;should be&amp;nbsp;'TRUE' instead of 'FALSE' in this way, and then proceed to obtain data&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'Noshowfcst_&amp;amp;LOC_ID'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384320#M11599</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-07-31T15:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if there is no column within a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384328#M11600</link>
      <description>&lt;P&gt;You say the column noshow_cancel_pred_pos exists in SAS data set HIST_5_6_POS_AADAL, and SAS says it doesn't exist, because it doesn't find that column name in that data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I believe SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you show us a screen capture that confirms the column of that name exists in that data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I do not know why, but I am expecting a SASLOG that shows the PROC SQL code that we are discussing resolved into actual text via MPRINT and MPRINTNEST turned on, and you are not showing it to me.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:43:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-determine-if-there-is-no-column-within-a-dataset/m-p/384328#M11600</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-31T15:43:56Z</dc:date>
    </item>
  </channel>
</rss>

