BookmarkSubscribeRSS Feed
cmj3773
Calcite | Level 5
 
28         DATA COMMMBRS4;
29         	Set COMMMBRS3;
30         	WHERE =(COV_MONTH GE &year_begin_date AND COV_MONTH LE &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.) > 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         

I have just inherited this code below. Trying to determine why I am getting this particular error. DATA COMMMBRS4;
Set COMMMBRS3;
WHERE =(COV_MONTH GE &year_begin_date AND COV_MONTH LE &year_end_date);
FORMAT member_key $20.;
member_key = mbr_pers_gen_key;
Age = intck('year', birth_date, cov_month) - (put(birth_date, mmddyy4.) > put(cov_month, mmddyy4.));
age_months = intck("month",birth_date,cov_month);
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);
RUN;                                                                                                                                                                                                                                                                                        

LOG Below 


28 DATA COMMMBRS4;
29 Set COMMMBRS3;
30 WHERE =(COV_MONTH GE &year_begin_date AND COV_MONTH LE &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.) > 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

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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 </> icon.

 

Insert Log Icon in SAS Communities.png

--
Paige Miller
Astounding
PROC Star

When KEEP appears as a stand-alone statement in a DATA step, it should not use an equal sign or parentheses.  Just KEEP a list of variable names;

 

And the note about the format statement should be obvious.  When a variable is numeric, do not apply a character format.  If you would prefer your variable to be changed to character, we can discuss that.

Tom
Super User Tom
Super User

Why are you assigning the result of that booelan expression to the variable WHERE?

The value you are trying to assign to the variable KEEP is not a valid expression.  You need operators between variables, like you had in the assignment statement for the variable WHERE.

 

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.  The KEEP statement probably will also not like the parentheses.

where (...);
keep ....;

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.  Perhaps something like:

set comments3(keep= .... where=(....));
ballardw
Super User

The KEEP statement does not use =  or variables in parentheses. That form is used as a data set option.

When you use Keep this way:

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

SAS thinks that your are 1) creating a new variable named Keep and assigning the values inside the ().

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.

Use this form to keep a list of variables with the Keep statement. (this is shorter than your version)

KEEP cov_month yearmo use_cov_month ISCURRMONTH isRolling12month aso_ind src_div_id src_mbr_id cov_month birth_date ;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 362 views
  • 0 likes
  • 5 in conversation