## grouping the value within subs group

Solved
Frequent Contributor
Posts: 75

# grouping the value within subs group

Hello, can anyone help me on this? How can I grouping all the data in a sub group sort by the same date beta into for example 6 groups? Thank you

beta                  date             group

Accepted Solutions
Solution
‎12-10-2012 08:08 PM
Super User
Posts: 10,770

## Re: grouping the value within subs group

RANK statement will keep the rank for you and remain the original data.

groups = 10;

by date;

var beta;

ranks rank_beta;

run;

All Replies
PROC Star
Posts: 8,163

## Re: grouping the value within subs group

What result are you trying to achieve given your example dataset?

Frequent Contributor
Posts: 75

## Re: grouping the value within subs group

I have sort the data by date and beta. I want to grouping the betas of the same date into 10 groups (1-10) with equally numbers of observation. so if date 01/01/1980 has 3 obs then I would have 3 groups, each has 1 obs, if date 04/01/1980 has 250 obs then i would have 10 groups each have 25 obs

PROC Star
Posts: 8,163

## Re: grouping the value within subs group

Can you use proc rank to do what you want?  Take a look at: Base SAS(R) 9.2 Procedures Guide

Frequent Contributor
Posts: 75

## Re: grouping the value within subs group

I have try something like this but it did not work.. the value of beta is replaced by the rank. how can I keep the beta and add a column for the rank

groups = 10;

by date;

var beta;

run;

Solution
‎12-10-2012 08:08 PM
Super User
Posts: 10,770

## Re: grouping the value within subs group

RANK statement will keep the rank for you and remain the original data.

groups = 10;

by date;

var beta;

ranks rank_beta;

run;

Frequent Contributor
Posts: 75

## Re: grouping the value within subs group

Thank you!

🔒 This topic is solved and locked.

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

Discussion stats
• 6 replies
• 230 views
• 0 likes
• 3 in conversation