BookmarkSubscribeRSS Feed
jen123
Fluorite | Level 6
Hi,

I have a situation where I need to calculate a performance based on 2 criteria. Below is what I have attempted in EG - but it errored.

The 1st 2 criterias are from one table, and the last 2 are from another table. There is no common column/field between the 2 tables - so I did not join them.

If the employee meets the two conditions, s/he is considered "EFFECTIVE".

Please advise how I should fix this. Thanks much!

***************

PROC SQL NOEXEC;
4 SELECT t1.WeightedAvg_NCL,
5 t1.ApprovalRate,
6 t2.Standard_NCL,
7 t2.Standard_ApprovalRate,
8 /* DecisionEffectiveness */
9 (if WeightedAvg_NCL <= Standard_NCL and ApprovalRate >= Standard_ApprovalRate then de='effective';
_______________
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, '.', /, <, <=, <>, =, >, >=, AND, EQ, EQT,
GE, GET, GT, GTT, LE, LET, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

9 ) AS
_
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
3 REPLIES 3
jen123
Fluorite | Level 6
I don't know why line 9 of the original posting is differnt once posted. In my code to use the characters to represent "greater than or Equal to" and "less than or equal to" - I don't spell it out in my codes. I just don't know why this forum deletes them from my codes below.

Here is what I would like for SAS EG to return one of the three performance:

*if WeightedAvg_NCL Less Than or Equal to Standard_NCL and ApprovalRate Greater Than or Equal to Standard_ApprovalRate then de='effective';

*if WeightedAvg_NCL > Standard_NCL and ApprovalRate < Standard_ApprovalRate then de='ineffective';

*if WeightedAvg_NCL = Standard_NCL and ApprovalRate = Standard_ApprovalRate then de='meet'



Thanks again!

****************
3 PROC SQL NOEXEC;
4 SELECT t1.WeightedAvg_NCL,
5 t1.ApprovalRate,
6 t2.Standard_NCL,
7 t2.Standard_ApprovalRate,
8 /* Decision Effectivness */
9 (if WeightedAvg_NCL <= Standard_NCL and ApprovalRate >= Standard_ApprovalRate then de='effective';
_______________
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, '.', /, <, <=, <>, =, >, >=, AND, EQ, EQT,
GE, GET, GT, GTT, LE, LET, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

9 if
__
180
ERROR 180-322: Statement is not valid or it is used out of proper order.

10 WeightedAvg_NCL > Standard_NCL and ApprovalRate < Standard_ApprovalRate then de='ineffective';
10 ! ) AS
_
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
DBailey
Lapis Lazuli | Level 10
There are no if statements in proc sql. You need to use a case statement.

case when a is true then b when c is true then d else e end as VarName

alternatively you can check multiple values of one variable as in

case a when b then c when d then e else f end as varname

means if a=b then varname=c elseif a=d then varname=e else f
TomKari
Onyx | Level 15
You'll have another problem. JOINs in SQL perform quite differently from SETs in DATA steps. If you don't provide join specifications, SQL will combine every record in dataset one with every record in dataset two, so you'll get a combinatorial explosion.

Tom

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 651 views
  • 0 likes
  • 3 in conversation