I need to update one observation that was a data entry error. I am trying to use an IF/THEN statement, but I'm having no luck. I can't figure out what is wrong.
data work.New_Teachers;
if Salary > $570,000 THEN Salary = $73,000;
run;
This results in the following errors:
ERROR 390-185: Expecting an relational or arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
Dataset is attached. Thanks for your help!
For future questions, please copy the CODE along with the error or other messages from the log and paste into a code box opened using the forum's {I} menu icon such as:
122 data work.New_Teachers; 123 if Salary > $570,000 THEN Salary = $73,000; - 390 76 ERROR 390-185: Expecting an relational or arithmetic operator. ERROR 76-322: Syntax error, statement will be ignored. 124 run;
The code box is important as the messages get reformatted by the forum software. Note that in the box above that there is an _ character under the $. That underscored indicates the position that SAS found something unexpected.
In this case a non-numeric value $.
There can be a lot of information in the log and learning how to read and interpret is important.
if Salary > 570000 THEN Salary = 73000;
btw, you are missing set statement to read your input dataset
For future questions, please copy the CODE along with the error or other messages from the log and paste into a code box opened using the forum's {I} menu icon such as:
122 data work.New_Teachers; 123 if Salary > $570,000 THEN Salary = $73,000; - 390 76 ERROR 390-185: Expecting an relational or arithmetic operator. ERROR 76-322: Syntax error, statement will be ignored. 124 run;
The code box is important as the messages get reformatted by the forum software. Note that in the box above that there is an _ character under the $. That underscored indicates the position that SAS found something unexpected.
In this case a non-numeric value $.
There can be a lot of information in the log and learning how to read and interpret is important.
Thanks for the feedback. I will recreate and resend
1 The SAS System Tuesday, October 23, 2018 05:32:00 PM
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='REPLACE';
4 %LET _CLIENTPROCESSFLOWNAME='5020';
5 %LET _CLIENTPROJECTPATH='C:\Users\amman\OneDrive\Desktop\Data Cleanse.egp';
6 %LET _CLIENTPROJECTPATHHOST='DESKTOP-39HS716';
7 %LET _CLIENTPROJECTNAME='Data Cleanse.egp';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 FILENAME EGHTML TEMP;
15 ODS HTML(ID=EGHTML) FILE=EGHTML
16 ENCODING='utf-8'
17 STYLE=HTMLBlue
18 STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
19 NOGTITLE
20 NOGFOOTNOTE
21 GPATH=&sasworklocation
22 ;
NOTE: Writing HTML(EGHTML) Body file: EGHTML
23
24 GOPTIONS ACCESSIBLE;
25
26 data work.New_Teachers;
27 if Salary > $570,000 THEN Salary = $73,000;
_
390
76
ERROR 390-185: Expecting an relational or arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
28 run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.NEW_TEACHERS may be incomplete. When this step was stopped there were 0 observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 423.84k
OS Memory 17064.00k
Timestamp 10/23/2018 05:33:21 PM
Step Count 2 Switch Count 1
Page Faults 0
Page Reclaims 101
Page Swaps 0
Voluntary Context Switches 5
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 160
29
30 GOPTIONS NOACCESSIBLE;
2 The SAS System Tuesday, October 23, 2018 05:32:00 PM
31 %LET _CLIENTTASKLABEL=;
32 %LET _CLIENTPROCESSFLOWNAME=;
33 %LET _CLIENTPROJECTPATH=;
34 %LET _CLIENTPROJECTPATHHOST=;
35 %LET _CLIENTPROJECTNAME=;
36 %LET _SASPROGRAMFILE=;
37 %LET _SASPROGRAMFILEHOST=;
38
39 ;*';*";*/;quit;run;
40 ODS _ALL_ CLOSE;
41
42
43 QUIT; RUN;
44
Here is the log in its entirety.
Thanks
Your feedback pointed me in the right direction. I removed the $ and , and reran. It worked. Thanks!
A
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.