DATA Step, Macro, Functions and more

Quartiling and finding the average in each quartile

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

Quartiling and finding the average in each quartile

My data is as follows:

data test;
input facilities_name $ sex totalpatients;
datalines;
ABCD 1 1850
CDXF 0 1234
XYZ 1 34567
qwerty 1 123
ASDF 0 1345567
rtyu 0 45
;
run;

 

I have to populate following table:

 

Sex

Total no of male(1)

3

Total no of female(0)

3

Facility rank by Totalpatients

 

       Quartile 1 (25)(mean N = XXX)

(No of facilities)

       Quartile 2 (50)

 

       Quartile 3 (75)

 

       Quartile 4 (100)

 

 

All suggestions are welcomed! 


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 23,343

Re: Quartiling and finding the average in each quartile

Posted in reply to pmpradhan

1. Use PROC RANK with GROUPS=4 to get the quartile. 

2. Use that data set with PROC MEANS to get the N and Mean

 


@pmpradhan wrote:

My data is as follows:

data test;
input facilities_name $ sex totalpatients;
datalines;
ABCD 1 1850
CDXF 0 1234
XYZ 1 34567
qwerty 1 123
ASDF 0 1345567
rtyu 0 45
;
run;

 

I have to populate following table:

 

Sex

Total no of male(1)

3

Total no of female(0)

3

Facility rank by Totalpatients

 

       Quartile 1 (25)(mean N = XXX)

(No of facilities)

       Quartile 2 (50)

 

       Quartile 3 (75)

 

       Quartile 4 (100)

 

 

All suggestions are welcomed! 


 

View solution in original post


All Replies
Solution
2 weeks ago
Super User
Posts: 23,343

Re: Quartiling and finding the average in each quartile

Posted in reply to pmpradhan

1. Use PROC RANK with GROUPS=4 to get the quartile. 

2. Use that data set with PROC MEANS to get the N and Mean

 


@pmpradhan wrote:

My data is as follows:

data test;
input facilities_name $ sex totalpatients;
datalines;
ABCD 1 1850
CDXF 0 1234
XYZ 1 34567
qwerty 1 123
ASDF 0 1345567
rtyu 0 45
;
run;

 

I have to populate following table:

 

Sex

Total no of male(1)

3

Total no of female(0)

3

Facility rank by Totalpatients

 

       Quartile 1 (25)(mean N = XXX)

(No of facilities)

       Quartile 2 (50)

 

       Quartile 3 (75)

 

       Quartile 4 (100)

 

 

All suggestions are welcomed! 


 

Contributor
Posts: 34

Re: Quartiling and finding the average in each quartile

Can you please post code as well. Thank you!

Respected Advisor
Posts: 2,836

Re: Quartiling and finding the average in each quartile

Posted in reply to pmpradhan

I think you need to give it a try yourself, and if you can't get it to work, show us the code and log.

 

You can look up PROC RANK and PROC MEANS in the documentation, they are relatively simple by SAS standards.

--
Paige Miller
Contributor
Posts: 34

Re: Quartiling and finding the average in each quartile

Thank you!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 141 views
  • 3 likes
  • 3 in conversation