BookmarkSubscribeRSS Feed
Ravikumarkummari
Quartz | Level 8

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.

8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

Ravikumarkummari
Quartz | Level 8

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.

ballardw
Super User

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.

Ravikumarkummari
Quartz | Level 8

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.

Haikuo
Onyx | Level 15

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.

Ravikumarkummari
Quartz | Level 8

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

Ksharp
Super User

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 .

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 947 views
  • 0 likes
  • 5 in conversation