BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hi all,

empidsalary
115000
220000
330000
445000
560000
670000
710000
820000
9100000
1035000
1140000
127000
1390000
1480000
1570000
1665000
1787000
1856000
198000
207000
2112000
2219000
2323000
2434000
2546000
2658000
2767000
2878000
295000
3084000

having the data like above.
empid and salary information is available in pdf.
min salary is 5000 and maximum is 100000.
i want the output like devide this salaries into 5 group.
each group contain 20000 salaries. i.e.

sal_group                              count(employees)

1st group 0-20000               number of employees in that each group.
2nd group 20000-40000       number of employees in that each group.
last group
80000-100000                     number of employees in that each group.

thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

data have;

input empid salary ;

cards;

1 15000

2 20000

3 30000

4 45000

5 60000

6 70000

7 10000

8 20000

9 100000

10 35000

11 40000

12 7000

13 90000

14 80000

15 70000

16 65000

17 87000

18 56000

19 8000

20 7000

21 12000

22 19000

23 23000

24 34000

25 46000

26 58000

27 67000

28 78000

29 5000

30 84000

;

run;

proc format;

value fmt

0-20000='1'

20000<-40000='2'

40000<-60000='3'

60000<-80000='4'

80000<-100000='5';

run;

data want;

set have;

group=put(salary,fmt.);

run;

View solution in original post

4 REPLIES 4
KachiM
Rhodochrosite | Level 12

I think a simple division of Salary will do the trick. No Proc is needed. You need an array to hold the counts.

data want;

array k[5] _temporary_;

   set have end = eof;

   i = ceil(salary / 20000);

   k + 1;

   if eof then

      do i = 1 to dim(k);

         group = i;

         low_value = (i - 1) * 20000;

         high_value = i * 20000;

         count = k;

         output;

      end;

keep group low_value high_value count;

run;

Ksharp
Super User

data have;

input empid salary ;

cards;

1 15000

2 20000

3 30000

4 45000

5 60000

6 70000

7 10000

8 20000

9 100000

10 35000

11 40000

12 7000

13 90000

14 80000

15 70000

16 65000

17 87000

18 56000

19 8000

20 7000

21 12000

22 19000

23 23000

24 34000

25 46000

26 58000

27 67000

28 78000

29 5000

30 84000

;

run;

proc format;

value fmt

0-20000='1'

20000<-40000='2'

40000<-60000='3'

60000<-80000='4'

80000<-100000='5';

run;

data want;

set have;

group=put(salary,fmt.);

run;

Ravikumarkummari
Quartz | Level 8

Thanks a lot xia keshan sir

Ksharp
Super User

data have;

input empid salary ;

cards;

1 15000

2 20000

3 30000

4 45000

5 60000

6 70000

7 10000

8 20000

9 100000

10 35000

11 40000

12 7000

13 90000

14 80000

15 70000

16 65000

17 87000

18 56000

19 8000

20 7000

21 12000

22 19000

23 23000

24 34000

25 46000

26 58000

27 67000

28 78000

29 5000

30 84000

;

run;

proc format;

value fmt

0-20000='1'

20000<-40000='2'

40000<-60000='3'

60000<-80000='4'

80000<-100000='5';

run;

data want;

set have;

group=put(salary,fmt.);

run;

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
  • 4 replies
  • 969 views
  • 0 likes
  • 3 in conversation