<?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: arithmetic operator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798704#M313985</link>
    <description>&lt;P&gt;The KEEP statement does not use =&amp;nbsp; or variables in parentheses. That form is used as a data set option.&lt;/P&gt;
&lt;P&gt;When you use Keep this way:&lt;/P&gt;
&lt;PRE&gt;34         	age_months = intck("month",birth_date,cov_month);
35         	KEEP =(cov_month yearmo use_cov_month ISCURRMONTH isRolling12month aso_ind src_div_id src_mbr_id cov_month birth_date
&lt;/PRE&gt;
&lt;P&gt;SAS thinks that your are 1) creating a new variable named Keep and assigning the values inside the ().&lt;/P&gt;
&lt;P&gt;Since the variable Keep is not defined SAS assumes you want a numeric variable and expects the variables in the () to have some sort of numeric operator involved (the more specific cause of that message.&lt;/P&gt;
&lt;P&gt;Use this form to keep a list of variables with the Keep statement. (this is shorter than your version)&lt;/P&gt;
&lt;PRE&gt;
KEEP cov_month yearmo use_cov_month ISCURRMONTH isRolling12month aso_ind src_div_id src_mbr_id cov_month birth_date ;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Feb 2022 18:15:18 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-02-25T18:15:18Z</dc:date>
    <item>
      <title>Error: arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798666#M313969</link>
      <description>&lt;PRE&gt; 
28         DATA COMMMBRS4;
29         	Set COMMMBRS3;
30         	WHERE =(COV_MONTH GE &amp;amp;year_begin_date AND COV_MONTH LE &amp;amp;year_end_date);
31         	FORMAT member_key $20.;
WARNING: Variable MEMBER_KEY has already been defined as numeric.
32         	member_key = mbr_pers_gen_key;
33         	Age = intck('year', birth_date, cov_month) - (put(birth_date, mmddyy4.) &amp;gt; put(cov_month, mmddyy4.));
34         	age_months = intck("month",birth_date,cov_month);
35         	KEEP =(cov_month yearmo use_cov_month ISCURRMONTH isRolling12month aso_ind src_div_id src_mbr_id cov_month birth_date
                             ______
                             388
                             76
35       ! age age_months mbr_cnt mbr_pers_gen_key member_key major_lob_cd fin_prod_cd CONSOL_MKT_DESC CNTY_CD SOLD_LEDGER_NBR
35       ! STATE_CD src_platform_cd SRC_CUST_ID SRC_RPT_CUST_ID SRC_PCP_PROV_ID SRC_CTRCT_ID CHART_OF_ACCTS_SKEY SRC_CUST_BEN_ID
35       ! FIN_SUB_CD);
ERROR 388-185: Expecting an arithmetic operator.

ERROR 76-322: Syntax error, statement will be ignored.

36         RUN;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.COMMMBRS4 may be incomplete.  When this step was stopped there were 0 observations and 157 variables.
WARNING: Data set WORK.COMMMBRS4 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
2                                                          The SAS System                            10:13 Friday, February 25, 2022

      memory              2282.12k
      OS Memory           22452.00k
      Timestamp           02/25/2022 11:23:15 AM
      Step Count                        28  Switch Count  82
      Page Faults                       0
      Page Reclaims                     353
      Page Swaps                        0
      Voluntary Context Switches        300
      Involuntary Context Switches      40
      Block Input Operations            0
      Block Output Operations           0
      

37         
38         %LET _CLIENTTASKLABEL=;
39         %LET _CLIENTPROCESSFLOWNAME=;
40         %LET _CLIENTPROJECTPATH=;
41         %LET _CLIENTPROJECTPATHHOST=;
42         %LET _CLIENTPROJECTNAME=;
43         %LET _SASPROGRAMFILE=;
44         %LET _SASPROGRAMFILEHOST=;
45         
46         ;*';*";*/;quit;run;
47         ODS _ALL_ CLOSE;
48         
49         
50         QUIT; RUN;
51         &lt;/PRE&gt;&lt;P&gt;I have just inherited this code below. Trying to determine why I am getting this particular error.&amp;nbsp;DATA COMMMBRS4;&lt;BR /&gt;Set COMMMBRS3;&lt;BR /&gt;WHERE =(COV_MONTH GE &amp;amp;year_begin_date AND COV_MONTH LE &amp;amp;year_end_date);&lt;BR /&gt;FORMAT member_key $20.;&lt;BR /&gt;member_key = mbr_pers_gen_key;&lt;BR /&gt;Age = intck('year', birth_date, cov_month) - (put(birth_date, mmddyy4.) &amp;gt; put(cov_month, mmddyy4.));&lt;BR /&gt;age_months = intck("month",birth_date,cov_month);&lt;BR /&gt;KEEP =(cov_month yearmo use_cov_month ISCURRMONTH isRolling12month aso_ind src_div_id src_mbr_id cov_month birth_date age age_months mbr_cnt mbr_pers_gen_key member_key major_lob_cd fin_prod_cd CONSOL_MKT_DESC CNTY_CD SOLD_LEDGER_NBR STATE_CD src_platform_cd SRC_CUST_ID SRC_RPT_CUST_ID SRC_PCP_PROV_ID SRC_CTRCT_ID CHART_OF_ACCTS_SKEY SRC_CUST_BEN_ID FIN_SUB_CD);&lt;BR /&gt;RUN;&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; &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; &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; &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; &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; &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; &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; &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; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LOG Below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;28 DATA COMMMBRS4;&lt;BR /&gt;29 Set COMMMBRS3;&lt;BR /&gt;30 WHERE =(COV_MONTH GE &amp;amp;year_begin_date AND COV_MONTH LE &amp;amp;year_end_date);&lt;BR /&gt;31 FORMAT member_key $20.;&lt;BR /&gt;WARNING: Variable MEMBER_KEY has already been defined as numeric.&lt;BR /&gt;32 member_key = mbr_pers_gen_key;&lt;BR /&gt;33 Age = intck('year', birth_date, cov_month) - (put(birth_date, mmddyy4.) &amp;gt; put(cov_month, mmddyy4.));&lt;BR /&gt;34 age_months = intck("month",birth_date,cov_month);&lt;BR /&gt;35 KEEP =(cov_month yearmo use_cov_month ISCURRMONTH isRolling12month aso_ind src_div_id src_mbr_id cov_month birth_date&lt;BR /&gt;______&lt;BR /&gt;388&lt;BR /&gt;76&lt;BR /&gt;35 ! age age_months mbr_cnt mbr_pers_gen_key member_key major_lob_cd fin_prod_cd CONSOL_MKT_DESC CNTY_CD SOLD_LEDGER_NBR&lt;BR /&gt;35 ! STATE_CD src_platform_cd SRC_CUST_ID SRC_RPT_CUST_ID SRC_PCP_PROV_ID SRC_CTRCT_ID CHART_OF_ACCTS_SKEY SRC_CUST_BEN_ID&lt;BR /&gt;35 ! FIN_SUB_CD);&lt;BR /&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;36 RUN;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.COMMMBRS4 may be incomplete. When this step was stopped there were 0 observations and 157 variables.&lt;BR /&gt;WARNING: Data set WORK.COMMMBRS4 was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.07 seconds&lt;BR /&gt;user cpu time 0.00 seconds&lt;BR /&gt;system cpu time 0.01 seconds&lt;BR /&gt;2 The SAS System 10:13 Friday, February 25, 2022&lt;/P&gt;&lt;P&gt;memory 2282.12k&lt;BR /&gt;OS Memory 22452.00k&lt;BR /&gt;Timestamp 02/25/2022 11:23:15 AM&lt;BR /&gt;Step Count 28 Switch Count 82&lt;BR /&gt;Page Faults 0&lt;BR /&gt;Page Reclaims 353&lt;BR /&gt;Page Swaps 0&lt;BR /&gt;Voluntary Context Switches 300&lt;BR /&gt;Involuntary Context Switches 40&lt;BR /&gt;Block Input Operations 0&lt;BR /&gt;Block Output Operations 0&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 17:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798666#M313969</guid>
      <dc:creator>cmj3773</dc:creator>
      <dc:date>2022-02-25T17:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Error: arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798674#M313970</link>
      <description>&lt;P&gt;I realize you are new here, but we would appreciate it if you format the log properly to increase readability. Copy the log as text and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&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="Insert Log Icon in SAS Communities.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66171iFEC370B1DBF07B28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Insert Log Icon in SAS Communities.png" alt="Insert Log Icon in SAS Communities.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 17:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798674#M313970</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-25T17:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Error: arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798675#M313971</link>
      <description>&lt;P&gt;When KEEP appears as a stand-alone statement in a DATA step, it should not use an equal sign or parentheses.&amp;nbsp; Just KEEP a list of variable names;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the note about the format statement should be obvious.&amp;nbsp; When a variable is numeric, do not apply a character format.&amp;nbsp; If you would prefer your variable to be changed to character, we can discuss that.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 17:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798675#M313971</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-02-25T17:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error: arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798690#M313977</link>
      <description>&lt;P&gt;Why are you assigning the result of that booelan expression to the variable WHERE?&lt;/P&gt;
&lt;P&gt;The value you are trying to assign to the variable KEEP is not a valid expression.&amp;nbsp; You need operators between variables, like you had in the assignment statement for the variable WHERE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you meant to use the WHERE and KEEP statement instead then remove the equal sign from both statements as that is making them assignment statements.&amp;nbsp; The KEEP statement probably will also not like the parentheses.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where (...);
keep ....;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you meant to use the WHERE= and KEEP= dataset options then they both need to be inside the set of dataset options listed after the name of a dataset.&amp;nbsp; Perhaps something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set comments3(keep= .... where=(....));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Feb 2022 17:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798690#M313977</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-25T17:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error: arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798704#M313985</link>
      <description>&lt;P&gt;The KEEP statement does not use =&amp;nbsp; or variables in parentheses. That form is used as a data set option.&lt;/P&gt;
&lt;P&gt;When you use Keep this way:&lt;/P&gt;
&lt;PRE&gt;34         	age_months = intck("month",birth_date,cov_month);
35         	KEEP =(cov_month yearmo use_cov_month ISCURRMONTH isRolling12month aso_ind src_div_id src_mbr_id cov_month birth_date
&lt;/PRE&gt;
&lt;P&gt;SAS thinks that your are 1) creating a new variable named Keep and assigning the values inside the ().&lt;/P&gt;
&lt;P&gt;Since the variable Keep is not defined SAS assumes you want a numeric variable and expects the variables in the () to have some sort of numeric operator involved (the more specific cause of that message.&lt;/P&gt;
&lt;P&gt;Use this form to keep a list of variables with the Keep statement. (this is shorter than your version)&lt;/P&gt;
&lt;PRE&gt;
KEEP cov_month yearmo use_cov_month ISCURRMONTH isRolling12month aso_ind src_div_id src_mbr_id cov_month birth_date ;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 18:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-arithmetic-operator/m-p/798704#M313985</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-25T18:15:18Z</dc:date>
    </item>
  </channel>
</rss>

