Help using Base SAS procedures

what is the process to group the observations

Reply
Frequent Contributor
Posts: 111

what is the process to group the observations

Hi all,

i have data set contain the variables emp_id, and salaries.

assume there will be 2000 records. emp_id are different and salaries are changed based upon their positions. salaries are min 10000 and maximum 500000.

devide this salaries into 10 groups then each group contain the salaries of 1000000. i.e. if the first ten members salary is equals to 10 lakhs then we want the output as.

sum of value     count(persons)

1000000                    10

1000000                    15

note:we don't take salaries between 1 and 10 lakh. we need the sum of persons salaries sum equals to 10 lakh.

in the second observation also same. The first case who are considered in the second record those persons are not considered. There are remaining of who we are considered in first observation.

like 10 groups we need. how this process is done in sas.

if you know please comment..

Thanks in advance.

Super User
Super User
Posts: 7,430

Re: what is the process to group the observations

Hi,

Perhaps some test data/required output would make your request clearer as I don't quite follow why you get two results?  As for grouping, well, you can use datastep with by group processing, proc means/summary/freq.  The way I tend to do grouping is:

proc sql;

     create table WANT as

     select     SALARY,

                    COUNT(distinct PERSON) as COUNT_PERSON

     from        HAVE

     group by SALARY

     having     SALARY=100000;

quit;

Frequent Contributor
Posts: 111

Re: what is the process to group the observations

its not group by salary. the salaries are different manner in this data.

if the sum of 20 persons is 1000000 then those are in one group.

and the remaining persons salaries equals to 100000 then those are second group. the first group persons are not included in second group.

like wise all the persons are covered.

Super User
Posts: 10,550

Re: what is the process to group the observations

Is the order of the original data of any importance to this process?

Is the 100000 group total: 1) exactly 1000000, 2) less than or equal to 1000000 but within a fixed difference (such as 999785 is within 500 of 1000000), 3) within some fixed amount of 100000, plus or minus some value.

What if after grouping to 1000000 you don't have 10 groups?

Is there a minimum number of people that must be in each group? A maximum?

You need to provide some data to show what this means:

we don't take salaries between 1 and 10 lakh. we need the sum of persons salaries sum equals to 10 lakh.

in the second observation also same. The first case who are considered in the second record those persons are not considered. There are remaining of who we are considered in first observation.

like 10 groups we need. how this process is done in sas.

Frequent Contributor
Posts: 111

Re: what is the process to group the observations

yes there is a lot of importance . its not exactly 10 lakh. its near to 10 lakh and also more than 10 lakh also but not exceeding . means below 10 lakh  ok and above also ok.  after grouping i need count of employees. This is for analysis purpose.

Respected Advisor
Posts: 3,124

Re: what is the process to group the observations

If you have SAS/OR, then check out SAS/OR(R) 9.3 User's Guide: Mathematical Programming

If you don't, you probably need data step/array loop.  Either way you want to provide some mocked data for people to work on if you need specific SAS code instead of general guidance.

Frequent Contributor
Posts: 111

Re: what is the process to group the observations

if any one know the answer please post how to by group the observations based on some value

here the value is 1000000. the sum of the employee salaries equals to 10 lakh. then

displays 10lakh  count(no of employes)

like wise the total data is covered. Based on 10 lakh i need groups its not between the 10 lakh its the sum of all the persons.

Super User
Super User
Posts: 7,430

Re: what is the process to group the observations

I have provided code above which covers your request to "group the observations based on some value here the value is 1000000".  Without further information, test data in, required output, and clarification of what the logic actually is, I don't see how further code can be provided?

Super User
Posts: 9,691

Re: what is the process to group the observations

post your sample data , and the output . You should know there might not be exactly be " the sum of persons salaries sum equals to 10 lakh" . if their salary is different .

Ask a Question
Discussion stats
  • 8 replies
  • 281 views
  • 0 likes
  • 5 in conversation