<?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: ERROR: Expecting an arithmetic expression. when trying to set variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360988#M85078</link>
    <description>&lt;P&gt;You've gotten most of the way there. &amp;nbsp;What you need to appreciate is how SAS stores date values. &amp;nbsp;They are integers, the number of days from January 1, 1960 to that particular day. &amp;nbsp;So the integers you are getting are perfectly valid SAS dates. &amp;nbsp;They can even be used in your program below. &amp;nbsp;This would be perfectly legal:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp_weekly_data;&lt;BR /&gt;set db.table(where = (20940 &amp;lt;= prod_date&amp;nbsp;&amp;lt; 20971));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get to that simply, since you already have macro variables with the proper values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set db.table (where=(&amp;amp;date1 &amp;lt;= prod_date &amp;lt; &amp;amp;date2));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure I'm using the proper macro variables to select the date ranges you want, but the lesson here is how to work with dates. &amp;nbsp;They are integer values. &amp;nbsp;Always.&lt;/P&gt;</description>
    <pubDate>Wed, 24 May 2017 01:54:50 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-05-24T01:54:50Z</dc:date>
    <item>
      <title>ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360938#M85048</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working on a report that takes in some date variables. these variables are set based on the day of the month that I run it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as an example, if I run a report on any day of this week week then the data should be pulled for last week and so on. to keep it simple, here is the matrix I am trying to create&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="674"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="151"&gt;&lt;STRONG&gt;&amp;nbsp;variable names:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="89"&gt;&lt;STRONG&gt;week&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="94"&gt;&lt;STRONG&gt;date&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="117"&gt;&lt;STRONG&gt;date1&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="112"&gt;&lt;STRONG&gt;date_today&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="111"&gt;&lt;STRONG&gt;date2&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;report execution dates&lt;/TD&gt;
&lt;TD&gt;Week&lt;/TD&gt;
&lt;TD&gt;month&lt;/TD&gt;
&lt;TD&gt;Start_date&lt;/TD&gt;
&lt;TD&gt;Mid_date&lt;/TD&gt;
&lt;TD&gt;End_date&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;May 8 to May 14&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;may2017&lt;/TD&gt;
&lt;TD&gt;'01may2017'd;&lt;/TD&gt;
&lt;TD&gt;'08MAY2017'd&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;May 15 to May 21&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;may2017&lt;/TD&gt;
&lt;TD&gt;'01may2017'd;&lt;/TD&gt;
&lt;TD&gt;'15MAY2017'd&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;May 22 to May Last Day&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;may2017&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;'01may2017'd;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;'22MAY2017'd&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;'01jun2017'd&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;June 1&amp;nbsp; to June 7&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;may2017&lt;/TD&gt;
&lt;TD&gt;'01may2017'd;&lt;/TD&gt;
&lt;TD&gt;'01JUN2017'd&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;jun 8 to jun 14&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;jun2017&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;TD&gt;'08jun2017'd&lt;/TD&gt;
&lt;TD&gt;'01jul2017'd&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;jun 15 to jun 21&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;jun2017&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;TD&gt;'15jun2017'd&lt;/TD&gt;
&lt;TD&gt;'01jul2017'd&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;jun 22 to jun Last Day&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;jun2017&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;TD&gt;'22jun2017'd&lt;/TD&gt;
&lt;TD&gt;'01jul2017'd&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;jul 1&amp;nbsp; to jul 7&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;jun2017&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;TD&gt;'01jul2017'd&lt;/TD&gt;
&lt;TD&gt;'01jul2017'd&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;based on the above matrix, if I run the macro today (may 23rd) then the dates should be set as follows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Week = 3&lt;/P&gt;
&lt;P&gt;date = may2017&lt;/P&gt;
&lt;P&gt;date1 =&amp;nbsp;'01may2017'd;&lt;/P&gt;
&lt;P&gt;date_today =&amp;nbsp;22MAY2017'd&lt;/P&gt;
&lt;P&gt;date2 =&amp;nbsp;'01jun2017'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is the code that I've created so far&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_;
	if 
		8 &amp;lt;= day(today()) &amp;lt;= 14 then
		do;
			week = 1;
			date = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.));
			date1 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),0)),date9.))%str(%')d;
			date2 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),1)),date9.))%str(%')d;
			date_today = %str(%')%str(%08)%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.))%str(%')d;
		end;
	else if 15 &amp;lt;= day(today()) &amp;lt;= 21 then
		do;
			week = 2;
			date = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.));
			date1 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),0)),date9.))%str(%')d;
			date2 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),1)),date9.))%str(%')d;
			date_today = %str(%')15%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.))%str(%')d;
		end;
	else if 22 &amp;lt;= day(today()) &amp;lt; 1 then
		do;
			week = 3;
			date = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.));
			date1 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),0)),date9.))%str(%')d;
			date2 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),1)),date9.))%str(%')d;
			date_today = %str(%')22%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.))%str(%')d;
		end;
	else if 1 &amp;lt;= day(today()) &amp;lt;= 7 then
		do;
			week = 4;
			date = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), -1)),MONYY7.));
			date1 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1)),date9.))%str(%')d;
			date2 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),0)),date9.))%str(%')d;
			date_today = %str(%')01%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.))%str(%')d;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp_weekly_data;&lt;BR /&gt; set db.table(where = ("&amp;amp;date_today"d &amp;lt;= prod_date&amp;nbsp;&amp;lt; "&amp;amp;date2"d));&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;--------------------------------&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;issue 1)&lt;/STRONG&gt; I am getting and error message&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expecting an arithmetic expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quesiton ) can I just call variable, let's say date2, as shown above or do I need to do something else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 22:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360938#M85048</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-23T22:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360942#M85051</link>
      <description>&lt;P&gt;And why don't you have the LOG results with the Error posted?&lt;/P&gt;
&lt;P&gt;And in a code box using the forum {i} menu icon?&lt;/P&gt;
&lt;P&gt;And why are using %sysfunc in a data step? %sysfunc is to execute a datastep function &lt;STRONG&gt;in macro code&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This&lt;/P&gt;
&lt;P&gt;date = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.));&lt;/P&gt;
&lt;P&gt;should probably be&lt;/P&gt;
&lt;P&gt;date = intnx('month',today,0);&lt;/P&gt;
&lt;P&gt;with possibly a 'b' if you want the first day of the month or 'E' if you want the last day of the month.&lt;/P&gt;
&lt;P&gt;And similaryly through the code.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 22:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360942#M85051</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-23T22:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360944#M85053</link>
      <description>&lt;P&gt;here is the log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3313 data _null_;&lt;BR /&gt;3314 Day_of_month = day(today());&lt;BR /&gt;3315 call symputx('Day_of_month',Day_of_month);&lt;BR /&gt;3316&lt;BR /&gt;3317 run;&lt;/P&gt;
&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.00 seconds&lt;BR /&gt; cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;3318&lt;BR /&gt;3319 data _null_;&lt;BR /&gt;3320 if&lt;BR /&gt;3321 8 &amp;lt;= day(today()) &amp;lt;= 14 then&lt;BR /&gt;3322 do;&lt;BR /&gt;3323 week = 1 ;&lt;BR /&gt;3324 date = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.));&lt;BR /&gt;3325 date1 =&lt;BR /&gt;3325! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),0)),date9.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3326 date2 =&lt;BR /&gt;3326! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),1)),date9.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3327 date_today =&lt;BR /&gt;3327! %str(%')%str(%08)%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),&lt;BR /&gt;3327! 0)),MONYY7.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3328 end;&lt;BR /&gt;3329 else if&lt;BR /&gt;3330 15 &amp;lt;= day(today()) &amp;lt;= 21 then&lt;BR /&gt;3331 do;&lt;BR /&gt;3332 week = 2 ;&lt;BR /&gt;3333 date = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.));&lt;BR /&gt;3334 date1 =&lt;BR /&gt;3334! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),0)),date9.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3335 date2 =&lt;BR /&gt;3335! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),1)),date9.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3336 date_today = %str(%')15%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),&lt;BR /&gt;3336! 0)),MONYY7.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3337 end;&lt;BR /&gt;3338 else if&lt;BR /&gt;3339 22 &amp;lt;= day(today()) &amp;lt; 1 then&lt;BR /&gt;3340 do;&lt;BR /&gt;3341 week = 3 ;&lt;BR /&gt;3342 date = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), 0)),MONYY7.));&lt;BR /&gt;3343 date1 =&lt;BR /&gt;3343! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),0)),date9.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3344 date2 =&lt;BR /&gt;3344! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),1)),date9.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3345 date_today = %str(%')22%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),&lt;BR /&gt;3345! 0)),MONYY7.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3346 end;&lt;BR /&gt;3347 else if&lt;BR /&gt;3348 1 &amp;lt;= day(today()) &amp;lt;= 7 then&lt;BR /&gt;3349 do;&lt;BR /&gt;3350 week = 4 ;&lt;BR /&gt;3351 date = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()), -1)),MONYY7.));&lt;BR /&gt;3352 date1 =&lt;BR /&gt;3352! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1)),date9.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3353 date2 =&lt;BR /&gt;3353! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),0)),date9.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3354 date_today = %str(%')01%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),&lt;BR /&gt;3354! 0)),MONYY7.))%str(%')d;&lt;BR /&gt;386: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;200: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;76: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN&lt;BR /&gt; where the error has occurred.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;3355 end;&lt;BR /&gt;3356 run;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.03 seconds&lt;BR /&gt; cpu time 0.03 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 22:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360944#M85053</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-23T22:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360945#M85054</link>
      <description>&lt;P&gt;Why do you need dates with the quotes/d literal?&lt;/P&gt;
&lt;P&gt;Why not use SAS dates throughout, it would be easier to see. To show in that format it means character variables which means you have to process it further. You're making this harder than it has to be basically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 22:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360945#M85054</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-23T22:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360956#M85061</link>
      <description>&lt;P&gt;I am trying to get to this matrix&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="674"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="151"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="89"&gt;week&lt;/TD&gt;
&lt;TD width="94"&gt;date&lt;/TD&gt;
&lt;TD width="117"&gt;date1&lt;/TD&gt;
&lt;TD width="112"&gt;date_today&lt;/TD&gt;
&lt;TD width="111"&gt;date2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;report execution dates&lt;/TD&gt;
&lt;TD&gt;Report Week&lt;/TD&gt;
&lt;TD&gt;Report month&lt;/TD&gt;
&lt;TD&gt;Report Start_date&lt;/TD&gt;
&lt;TD&gt;Report Mid_date&lt;/TD&gt;
&lt;TD&gt;Report End_date&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;May 8 to May 14&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;may2017&lt;/TD&gt;
&lt;TD&gt;'01may2017'd;&lt;/TD&gt;
&lt;TD&gt;'08MAY2017'd&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;May 15 to May 21&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;may2017&lt;/TD&gt;
&lt;TD&gt;'01may2017'd;&lt;/TD&gt;
&lt;TD&gt;'15MAY2017'd&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;May 22 to May Last Day&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;may2017&lt;/TD&gt;
&lt;TD&gt;'01may2017'd;&lt;/TD&gt;
&lt;TD&gt;'22MAY2017'd&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;June 1&amp;nbsp; to June 7&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;may2017&lt;/TD&gt;
&lt;TD&gt;'01may2017'd;&lt;/TD&gt;
&lt;TD&gt;'01JUN2017'd&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;jun 8 to jun 14&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;jun2017&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;TD&gt;'08jun2017'd&lt;/TD&gt;
&lt;TD&gt;'01jul2017'd;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;jun 15 to jun 21&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;jun2017&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;TD&gt;'15jun2017'd&lt;/TD&gt;
&lt;TD&gt;'01jul2017'd;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;jun 22 to jun Last Day&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;jun2017&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;TD&gt;'22jun2017'd&lt;/TD&gt;
&lt;TD&gt;'01jul2017'd;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;jul 1&amp;nbsp; to jul 7&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;jun2017&lt;/TD&gt;
&lt;TD&gt;'01jun2017'd;&lt;/TD&gt;
&lt;TD&gt;'01jul2017'd&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;'01jul2017'd;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&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;P&gt;her is what I have (as a simplified sample)...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;format week comma10.0;&lt;BR /&gt;format date date1 date2 date_today date9.;&lt;BR /&gt; week = 1 ;&lt;BR /&gt; date = %sysfunc(intnx('month',today,0));&lt;BR /&gt; date1 = %sysfunc(intnx('month',today,0, 'b'));&lt;BR /&gt; date2 = %sysfunc(intnx('month',today,1, 'b'));&lt;BR /&gt; date_today = %str(%08)%sysfunc(intnx('month',today,0));&lt;/P&gt;
&lt;P&gt;call symputx('week',week);&lt;BR /&gt;call symputx('date',date);&lt;BR /&gt;call symputx('date1',date1);&lt;BR /&gt;call symputx('date2',date2);&lt;BR /&gt;call symputx('date_today',date_today);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;----------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;150 data _null_;&lt;BR /&gt;151 format week comma10.0;&lt;BR /&gt;152 format date date1 date2 date_today date9.;&lt;BR /&gt;153 week = 1 ;&lt;BR /&gt;154 date = %sysfunc(intnx('month',today,0));&lt;BR /&gt;ERROR: Argument 2 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is not&lt;BR /&gt; a number.&lt;BR /&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution&lt;BR /&gt; of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is terminated.&lt;BR /&gt;155 date1 = %sysfunc(intnx('month',today,0, 'b'));&lt;BR /&gt;ERROR: Argument 2 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is not&lt;BR /&gt; a number.&lt;BR /&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution&lt;BR /&gt; of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is terminated.&lt;BR /&gt;156 date2 = %sysfunc(intnx('month',today,1, 'b'));&lt;BR /&gt;ERROR: Argument 2 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is not&lt;BR /&gt; a number.&lt;BR /&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution&lt;BR /&gt; of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is terminated.&lt;BR /&gt;157 date_today = %str(%08)%sysfunc(intnx('month',today,0));&lt;BR /&gt;ERROR: Argument 2 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is not&lt;BR /&gt; a number.&lt;BR /&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution&lt;BR /&gt; of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is terminated.&lt;BR /&gt;NOTE: Line generated by the macro function "STR".&lt;BR /&gt;1 %08&lt;BR /&gt; -&lt;BR /&gt; 386&lt;BR /&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;/P&gt;
&lt;P&gt;NOTE: Line generated by the macro function "STR".&lt;BR /&gt;1 %08&lt;BR /&gt; -&lt;BR /&gt; 200&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;NOTE: Line generated by the macro function "STR".&lt;BR /&gt;1 %08&lt;BR /&gt; -&lt;BR /&gt; 76&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;158&lt;BR /&gt;159&lt;BR /&gt;160 call symputx('week',week);&lt;BR /&gt;161 call symputx('date',date);&lt;BR /&gt;162 call symputx('date1',date1);&lt;BR /&gt;163 call symputx('date2',date2);&lt;BR /&gt;164 call symputx('date_today',date_today);&lt;BR /&gt;165 run;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.01 seconds&lt;BR /&gt; cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;166&lt;BR /&gt;167&lt;BR /&gt;168&lt;BR /&gt;WARNING: Apparent symbolic reference DATE_TODAY not resolved.&lt;BR /&gt;169 %put &amp;amp;week &amp;amp;date &amp;amp;date1 &amp;amp;date2 &amp;amp;date_today;&lt;BR /&gt;1 . . . &amp;amp;date_today&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-----------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please advise what am I doing wrong here&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;week &amp;amp;date &amp;amp;date1 &amp;amp;date2 &amp;amp;date_today;&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>Tue, 23 May 2017 23:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360956#M85061</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-23T23:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360969#M85068</link>
      <description>&lt;P&gt;Your mistakes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're mixing macro and data step logic.&amp;nbsp;For example, you don't need %SYSFUNC() in data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TODAY is a function, you're missing the parentheses.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you're trying to calculate the date_today you're using STR(08) - It's not clear what you're trying to do here. If you're trying to align the date to the end of the period why not use INTNX again with a WEEK interval and put it to the end or beginning?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're writing a macro, ALWAYS have BASE code that works first. Otherwise you'll run into these issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 00:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360969#M85068</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-24T00:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360978#M85071</link>
      <description>&lt;P&gt;here is the modified base code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;format week comma10.0;&lt;BR /&gt;format date date1 date2 date_today date9.;&lt;BR /&gt; week = 1 ;&lt;BR /&gt; date = intnx('month',today(),0);&lt;BR /&gt; date1 = intnx('month',today(),0, 'b');&lt;BR /&gt; date2 = intnx('month',today(),1, 'b');&lt;BR /&gt; date_today = intnx('week',today(),1);&lt;/P&gt;
&lt;P&gt;call symputx('week',week);&lt;BR /&gt;call symputx('date',date);&lt;BR /&gt;call symputx('date1',date1);&lt;BR /&gt;call symputx('date2',date2);&lt;BR /&gt;call symputx('date_today',date_today);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;week &amp;amp;date &amp;amp;date1 &amp;amp;date2 &amp;amp;date_today;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;316 %put &amp;amp;week &amp;amp;date &amp;amp;date1 &amp;amp;date2 &amp;amp;date_today;&lt;BR /&gt;1 20940 20940 20971 20967&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-----------------&lt;/P&gt;
&lt;P&gt;seems like issue with the format... not sure what causing it as I am using&amp;nbsp;&lt;SPAN&gt;date9. format as you can see from the code above&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 00:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360978#M85071</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-24T00:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360986#M85076</link>
      <description>&lt;P&gt;Well, that's a bit closer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;value&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;specifies a character or numeric constant, variable, or expression. &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;If value is numeric, SAS converts the value to a character string using the BEST. format and does not issue a note to the SAS log.&lt;/STRONG&gt;&lt;/FONT&gt; Leading and trailing blanks are removed, and the resulting character string is assigned to the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to control the format, use PUT() to convert it with DATE9.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I REALLY REALLY don't recommend this though, use the values you have. Reveiw how SAS calculates dates and why you should use those numbers, I don't have time to write out all the reasons why, but if you understand the basics of dates it'll make sense to you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 01:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360986#M85076</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-24T01:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360988#M85078</link>
      <description>&lt;P&gt;You've gotten most of the way there. &amp;nbsp;What you need to appreciate is how SAS stores date values. &amp;nbsp;They are integers, the number of days from January 1, 1960 to that particular day. &amp;nbsp;So the integers you are getting are perfectly valid SAS dates. &amp;nbsp;They can even be used in your program below. &amp;nbsp;This would be perfectly legal:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp_weekly_data;&lt;BR /&gt;set db.table(where = (20940 &amp;lt;= prod_date&amp;nbsp;&amp;lt; 20971));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get to that simply, since you already have macro variables with the proper values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set db.table (where=(&amp;amp;date1 &amp;lt;= prod_date &amp;lt; &amp;amp;date2));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure I'm using the proper macro variables to select the date ranges you want, but the lesson here is how to work with dates. &amp;nbsp;They are integer values. &amp;nbsp;Always.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 01:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360988#M85078</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-24T01:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360990#M85080</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22922"&gt;@tparvaiz&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working on a report that takes in some date variables. these variables are set based on the day of the month that I run it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as an example, if I run a report on any day of this week week then the data should be pulled for last week and so on. to keep it simple, here is the matrix I am trying to create&lt;/P&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;&lt;BR /&gt;Your 'matrix' may be helpful in understanding but it's not a good way to drive your reports. You can use the macro variables directly you don't need to create that matrix. Creating them on the fly each time will have very little overhead in your process.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You never 'finished' this question, did the options here not work in some manner? Otherwise you should consider marking the appropriate answer as the solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/how-to-automatically-find-week-number-of-the-month/m-p/359845#M84648" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/how-to-automatically-find-week-number-of-the-month/m-p/359845#M84648&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 02:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/360990#M85080</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-24T02:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/361334#M85190</link>
      <description>&lt;P&gt;Folks, thanks again for your assistance. I think I am getting there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is my code so far&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;------------------CODE------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;format week comma10.0;&lt;BR /&gt;format date1 date2 date_today date9.;&lt;BR /&gt;format date MONYY.;&lt;/P&gt;
&lt;P&gt;if &lt;BR /&gt; 8 &amp;lt;= day(today()) &amp;lt;= 14 then &lt;BR /&gt; do;&lt;BR /&gt; week = 1 ;&lt;BR /&gt; date = intnx('month',today(),0);&lt;BR /&gt; date1 = intnx('month',today(),0, 'b');&lt;BR /&gt; date2 = intnx('month',today(),1, 'b');&lt;BR /&gt; date_today = intnx('week',today(),0); &lt;BR /&gt; end;&lt;BR /&gt;else if&lt;BR /&gt; 15 &amp;lt;= day(today()) &amp;lt;= 21 then &lt;BR /&gt; do;&lt;BR /&gt; week = 2 ;&lt;BR /&gt; date = intnx('month',today(),0);&lt;BR /&gt; date1 = intnx('month',today(),0, 'b');&lt;BR /&gt; date2 = intnx('month',today(),1, 'b');&lt;BR /&gt; date_today = intnx('week',today(),0); &lt;BR /&gt; end;&lt;BR /&gt;else if&lt;BR /&gt; 22 &amp;lt;= day(today()) &amp;lt;= 31 then &lt;BR /&gt; do;&lt;BR /&gt; week = 3 ;&lt;BR /&gt; date = intnx('month',today(),0);&lt;BR /&gt; date1 = intnx('month',today(),0, 'b');&lt;BR /&gt; date2 = intnx('month',today(),1, 'b');&lt;BR /&gt; date_today = intnx('week',today(),0);&lt;BR /&gt; end;&lt;BR /&gt;else if&lt;BR /&gt; 1 &amp;lt;= day(today()) &amp;lt;= 7 then &lt;BR /&gt; do;&lt;BR /&gt; week = 4 ;&lt;BR /&gt; date = intnx('month',today(),-1);&lt;BR /&gt; date1 = intnx('month',today(),-1, 'b');&lt;BR /&gt; date2 = intnx('month',today(),0, 'b');&lt;BR /&gt; date_today = intnx('week',today(),0); &lt;BR /&gt; end;&lt;/P&gt;
&lt;P&gt;put date1 date2 date_today DATE9.;&lt;BR /&gt;put date MONYY.;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;call symputx('week',week);&lt;BR /&gt;call symputx('date',date);&lt;BR /&gt;call symputx('date1',date1);&lt;BR /&gt;call symputx('date2',date2);&lt;BR /&gt;call symputx('date_today',date_today);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%put date = &amp;amp;date. date1 = &amp;amp;date1. date2 = &amp;amp;date2. date_today = &amp;amp;date_today. week = &amp;amp;week.;&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;P&gt;--------------------------Log file -----------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5676 else if&lt;BR /&gt;5677 1 &amp;lt;= day(today()) &amp;lt;= 7 then&lt;BR /&gt;5678 do;&lt;BR /&gt;5679 week = 4 ;&lt;BR /&gt;5680 date = intnx('month',today(),-1);&lt;BR /&gt;5681 date1 = intnx('month',today(),-1, 'b');&lt;BR /&gt;5682 date2 = intnx('month',today(),0, 'b');&lt;BR /&gt;5683 date_today = intnx('week',today(),0);&lt;BR /&gt;5684 end;&lt;BR /&gt;5685&lt;BR /&gt;5686 put date1 date2 date_today DATE9.;&lt;BR /&gt;5687 put date MONYY.;&lt;BR /&gt;5688&lt;BR /&gt;5689&lt;BR /&gt;5690 call symputx('week',week);&lt;BR /&gt;5691 call symputx('date',date);&lt;BR /&gt;5692 call symputx('date1',date1);&lt;BR /&gt;5693 call symputx('date2',date2);&lt;BR /&gt;5694 call symputx('date_today',date_today);&lt;BR /&gt;5695&lt;BR /&gt;5696 run;&lt;/P&gt;
&lt;P&gt;01MAY2017 01JUN2017 21MAY2017&lt;BR /&gt;MAY17&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.01 seconds&lt;BR /&gt; cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SYMBOLGEN: Macro variable DATE resolves to 20940&lt;BR /&gt;5697&lt;BR /&gt;SYMBOLGEN: Macro variable DATE1 resolves to 20940&lt;BR /&gt;5698&lt;BR /&gt;SYMBOLGEN: Macro variable DATE2 resolves to 20971&lt;BR /&gt;5699&lt;BR /&gt;SYMBOLGEN: Macro variable DATE_TODAY resolves to 20960&lt;BR /&gt;5700&lt;BR /&gt;SYMBOLGEN: Macro variable WEEK resolves to 3&lt;BR /&gt;5701 %put date = &amp;amp;date. date1 = &amp;amp;date1. date2 = &amp;amp;date2. date_today = &amp;amp;date_today. week = &amp;amp;week.;&lt;BR /&gt;date = 20940 date1 = 20940 date2 = 20971 date_today = 20960 week = 3&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;P&gt;----------------------------------------------------Remaining Issue ---------------------------------------&lt;/P&gt;
&lt;P&gt;my date_today is not set up properly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want date today to be as follows&lt;/P&gt;
&lt;P&gt;if today is&amp;nbsp;between 8th day of the month to 14th day of the month: 8th day of the month, as en example 8May2017&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if today is between 15th day of the month to 21nd&amp;nbsp;day of the month: 15th day of the month, as en example 15May2017&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if today is between &lt;/SPAN&gt;&lt;SPAN&gt;22nd&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;day of the month to &lt;/SPAN&gt;&lt;SPAN&gt;31st&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;day of the month: &lt;/SPAN&gt;&lt;SPAN&gt;22nd&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;day of the month, as en example &lt;/SPAN&gt;&lt;SPAN&gt;22&lt;/SPAN&gt;&lt;SPAN&gt;May2017&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried differnet logic as posted above but nothing is work so far, please advise&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 19:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/361334#M85190</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-24T19:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/361368#M85205</link>
      <description>&lt;P&gt;Since you already have DATE2 holding the first day of the current month, DATE_TODAY can be built from that.&amp;nbsp; There may be more elegant ways, but this should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;day_of_month = day(today());&lt;/P&gt;
&lt;P&gt;if day_of_month &amp;lt; 8 then date_today = date2;&lt;/P&gt;
&lt;P&gt;else if day_of_month &amp;lt; 15 then date_today = date2 + 7;&lt;/P&gt;
&lt;P&gt;else if day_of_month &amp;lt; 22 then date_today = date2 + 14;&lt;/P&gt;
&lt;P&gt;else date_today = date2 + 21;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 19:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/361368#M85205</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-24T19:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/361401#M85221</link>
      <description>&lt;P&gt;You should use a DO loop rather than repeat your code. I think the code from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;will help with the other date calcs so you don't need the IF statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do week=1 to 4;
    date = intnx('month',today(),0);
    date1 = intnx('month',today(),0, 'b');
    date2 = intnx('month',today(),1, 'b');
    date_today = intnx('week',today(),0); 
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 May 2017 21:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/361401#M85221</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-24T21:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting an arithmetic expression. when trying to set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/361408#M85224</link>
      <description>&lt;P&gt;thanks everyone for your assistance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Talha&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 21:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-an-arithmetic-expression-when-trying-to-set/m-p/361408#M85224</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-24T21:41:13Z</dc:date>
    </item>
  </channel>
</rss>

