BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
cleokatt
Calcite | Level 5

Hi

 

I'm trying to calculate outliners within a datset trying:


proc sql;
SELECT
CASE
WHEN a.row_num <= ceil(0.25 * b.total_rows) THEN 1
WHEN a.row_num <= ceil(0.5 * b.total_rows) THEN 2
WHEN a.row_num <= ceil(0.75 * b.total_rows) THEN 3
ELSE 4
END AS quartile,
AVG(a.value) AS quartile_value
FROM
(SELECT value, row_num() AS row_num FROM MYDATASET) AS a
INNER JOIN
(SELECT count(*) AS total_rows FROM MYDATASET) AS b
ON
1=1
GROUP BY
quartile;
quit;

 

My dataset have three col=sector (char), country (char), value (num)

 

ERROR: Function ROW_NUM could not be located.
ERROR: Expression using less than or equal (<=) has components that are of different data
types.
ERROR: Expression using less than or equal (<=) has components that are of different data
types.
ERROR: Expression using less than or equal (<=) has components that are of different data
types.
1451 quit;


I can't use OVER or HAVING or such beacuse of my version of my computer, 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

SQL extension row_num() is a function available in some databases but not in the SAS SQL flavour. 

Look into Proc Univariate that provides a lot of stats for what I believe you're after. 

View solution in original post

1 REPLY 1
Patrick
Opal | Level 21

SQL extension row_num() is a function available in some databases but not in the SAS SQL flavour. 

Look into Proc Univariate that provides a lot of stats for what I believe you're after. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 1 reply
  • 327 views
  • 0 likes
  • 2 in conversation