I am one variable and the max and min of the variable. How can I create equally spaced 10 bins from min to max? I feel proc rank won't work because I want equally spaced. For example, min=1, max =100, then if a number is 92, then it falls into bin 9, if it is 72, then it falls into bin 7.
Asked
Active
Viewed 794 times
0
-
You want a histogram, it sounds like? What does "Create" mean? – Joe Feb 27 '18 at 15:36
-
Equally spaced in terms of the number in each bin or the size of each bin? Assuming its the size, you first need the min/max, divide that by 10 to get the size of each bin and then allocate those to groups. – Reeza Feb 27 '18 at 15:40
-
Are min and max of the values present or of the expected/allowed values. For data values present, consider 13,15,19. min=13 and max=19. Do you want 10 bins covering 13 to 19 ? If so, try `Proc RANK GROUPS=10` – Richard Feb 27 '18 at 18:13
1 Answers
0
It's not entirely clear what you want to do. Based on what you've posted you can do the following:
1) create new variable = ((old variable - min)/ (max value - min)) * 100
that creates a variable that is now between 0 and 100
2) bin into 10 bins: int(new variable / 10) will give you the bin number
if this is what you are looking for post a sample data set and I can supply additional code.

DCR
- 14,737
- 12
- 52
- 115