How to create groups of variable by deciles in SAS?

sas
data_wrangling

#1

Hi,

I have data set (having basic detail of call with their average handling time). Now I want to create a new variable based on decile of avg_time.

Example:

DATA Call;
INPUT Call_ID Call_Type AVG_Time ;
DATALINES;
A1234 A 12:03
A3456 B 24:08
.
.
.
.
.
A5678 C 09:54
;

Please help to create a variable based decile on avg_time.

Regards,
Rahul


#2

@rahul

Procedure Proc Rank can help you to perform it. I have created a sample data set using your example and generate a rank based on avg_time.

Data set created

DATA Call;
INPUT Call_ID $ Call_Type $ AVG_Time ;
DATALINES;
A1234 A 12.03
A3456 B 24.08
A3457 B 23.08
A3455 B 22.08
A3454 B 21.08
A3453 B 20.08
A3452 B 19.08
A3451 B 18.08
A3450 B 17.08
A3449 B 16.08
A3448 B 15.08
A3447 B 14.08
A3446 B 13.08
A5678 C 09.54
;

Decile generated using proc rank

proc rank data=call out=result descending;
   var avg_time;
   ranks avg_time_Rank;
run;

Regards,
Imran