<?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: Using a PUT in a WHERE statement in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395355#M25449</link>
    <description>&lt;P&gt;All good Tom - appreciate the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm now getting no data returned due to the date being blank (if I read the note properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;NOTE: There were 0 observations read from the data set SDPTEL.EMPLOYEE_TELEPHONY.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE Week_end_dt='&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .'D;&lt;/FONT&gt;&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;&lt;PRE&gt;&lt;FONT color="#000000"&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	call symput('DateVar', put(sunday, date9.));
run;

%PUT &amp;amp;DateVar;


Data work.TT_Weekly_report;
	Set Data.Employee;
	Keep Week_end_dt EVENT_DT Cluster Queue_CD TOTAL_CALLS TALK_TIME MBL;
	Where Week_end_dt =  "&amp;amp;DateVar."d;
RUN;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&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>Wed, 13 Sep 2017 01:32:47 GMT</pubDate>
    <dc:creator>DME790</dc:creator>
    <dc:date>2017-09-13T01:32:47Z</dc:date>
    <item>
      <title>Using a PUT in a WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395339#M25445</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do reports that use the previous Sunday as the end date. I can calculate the Sunday based on the data _null_ step, but how do I now use that in the Where Week_end_dt =&amp;nbsp; &lt;EM&gt;'Sunday.'d&lt;/EM&gt;;&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;data _null_; 
    ref=today();
    sunday = intnx('week1.2',ref,-1,'End');
    format _all_ Date10.; 
    put Sunday;
    run; 



	
Data work.TT_Weekly_report;
	Set Data.Employee;
	Keep Week_end_dt EVENT_DT Cluster Queue_CD TOTAL_CALLS TALK_TIME MBL;
	Where Week_end_dt =  'Sunday.'d;
	RUN;
		&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dean&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2017 23:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395339#M25445</guid>
      <dc:creator>DME790</dc:creator>
      <dc:date>2017-09-12T23:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using a PUT in a WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395345#M25446</link>
      <description>&lt;P&gt;Good start! This is where you need SAS macro variables. They are always character, so you need to convert your date into a character version.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your data _null_ step, switch out your format and put statements, and instead use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call symput('DateVar', put(sunday, date9.));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to load the formatted date into a macro variable named DateVar.&lt;/P&gt;
&lt;P&gt;And then in your second step, use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where Week_end_dt =&amp;nbsp; "&amp;amp;Sunday."d;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need double quotes to allow the substitution.&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 00:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395345#M25446</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-09-13T00:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using a PUT in a WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395347#M25447</link>
      <description>&lt;P&gt;Thanks Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I must still be missing something sorry. I have changed the code to:&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;data _null_; 
       call symput('DateVar', put(sunday, date9.));
    run; 

%PUT &amp;amp;Sunday.;

Data work.TT_Weekly_report;
	Set Data.Employee;
	Keep Week_end_dt EVENT_DT Cluster Queue_CD TOTAL_CALLS TALK_TIME MBL;
	Where Week_end_dt =  "&amp;amp;Sunday."d;
	RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and I get this error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;29&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Where Week_end_dt =&amp;nbsp; "&amp;amp;Sunday."d;&lt;BR /&gt;NOTE: Line generated by the macro variable "SUNDAY".&lt;BR /&gt;29&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "" 10SEP2017"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color="#ff0000"&gt;&amp;nbsp; __&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 76&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;ERROR: Syntax error while parsing WHERE clause.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, GE, GT, LE, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LT, NE, NOT, OR, ^, ^=, |, ||, ~, ~=.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dean&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 00:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395347#M25447</guid>
      <dc:creator>DME790</dc:creator>
      <dc:date>2017-09-13T00:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using a PUT in a WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395353#M25448</link>
      <description>&lt;P&gt;Sorry, brain fart.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The name of the macro variabel is DateVar. I forgot to change it in the second reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use &amp;amp;DateVar. instead of &amp;amp;Sunday.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 01:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395353#M25448</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-09-13T01:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using a PUT in a WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395355#M25449</link>
      <description>&lt;P&gt;All good Tom - appreciate the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm now getting no data returned due to the date being blank (if I read the note properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;NOTE: There were 0 observations read from the data set SDPTEL.EMPLOYEE_TELEPHONY.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE Week_end_dt='&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .'D;&lt;/FONT&gt;&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;&lt;PRE&gt;&lt;FONT color="#000000"&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	call symput('DateVar', put(sunday, date9.));
run;

%PUT &amp;amp;DateVar;


Data work.TT_Weekly_report;
	Set Data.Employee;
	Keep Week_end_dt EVENT_DT Cluster Queue_CD TOTAL_CALLS TALK_TIME MBL;
	Where Week_end_dt =  "&amp;amp;DateVar."d;
RUN;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&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>Wed, 13 Sep 2017 01:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395355#M25449</guid>
      <dc:creator>DME790</dc:creator>
      <dc:date>2017-09-13T01:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using a PUT in a WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395358#M25451</link>
      <description>&lt;P&gt;There's no SET statement in your data _null_ step.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 01:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395358#M25451</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T01:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using a PUT in a WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395368#M25452</link>
      <description>Hi Reeza - I'm not sure what you mean by not having a SET statement in the Data _NULL_ step.</description>
      <pubDate>Wed, 13 Sep 2017 03:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395368#M25452</guid>
      <dc:creator>DME790</dc:creator>
      <dc:date>2017-09-13T03:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using a PUT in a WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395373#M25453</link>
      <description>&lt;PRE&gt;&lt;FONT color="#000000"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; _null_&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;BR /&gt;call &lt;SPAN class="token function"&gt;symput&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'DateVar'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;sunday&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can't create a macro variable out of nothing. You're referencing the variable SUNDAY&amp;nbsp;in the data step but there's no data set with a variable named SUNDAY and 'sunday' doesn't have any meaning so I'm not sure what you're trying to do here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You had it working before, but you changed it for some reason?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 03:37:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395373#M25453</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T03:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using a PUT in a WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395375#M25454</link>
      <description>&lt;P&gt;Macro variables, in this usage are text replacement, literally like find and replace.&lt;/P&gt;
&lt;P&gt;INTNX is used to align the date (4th parameter) to the beginning of the week.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symputx('DateVar', put(intnx('week', today(), 0, 'b'), date9.));
run;

Data work.TT_Weekly_report;
	Set Data.Employee;
	Keep Week_end_dt EVENT_DT Cluster Queue_CD TOTAL_CALLS TALK_TIME MBL;
	Where Week_end_dt =  "&amp;amp;DateVar"d;
	RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could just apply that in your WHERE clause directly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data work.TT_Weekly_report;
	Set Data.Employee;
	Keep Week_end_dt EVENT_DT Cluster Queue_CD TOTAL_CALLS TALK_TIME MBL;
	Where Week_end_dt =  intnx('week', today(), 0, 'b');
	RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Sep 2017 03:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-PUT-in-a-WHERE-statement/m-p/395375#M25454</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T03:41:28Z</dc:date>
    </item>
  </channel>
</rss>

