Hi all,
I have a question about using an output result for IF statement.
For example, I have a following data about size of a product.
My plan is to:
As I have 32 products, I would like to know if it can be done in a loop or something. Thanks in advance.
Best,
David
Have
| Size |
| 0.5 |
| 0.5 |
| 1 |
| 1 |
| 1 |
| 2 |
| 1 |
| 1 |
| 1 |
| 2 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
Want
| Size | Group |
| 0.5 | 1 |
| 0.5 | 1 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 2 | 3 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 2 | 3 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
| 1 | 2 |
Use PROC RANK with GROUPS=4. This will place each value into one of 4 groups by quartiles, numbered as 0 through 3. If you want to have the group 25 percentile to 75 percentile, you can combine groups 1 and 2 from PROC RANK. No looping is needed, PROC RANK supports the use of a BY statement, so you can run PROC RANK once on all 32 products.
Example: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p12aek9f6xhl1zn1puuuot19wqi7.htm
Use PROC RANK with GROUPS=4. This will place each value into one of 4 groups by quartiles, numbered as 0 through 3. If you want to have the group 25 percentile to 75 percentile, you can combine groups 1 and 2 from PROC RANK. No looping is needed, PROC RANK supports the use of a BY statement, so you can run PROC RANK once on all 32 products.
Example: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p12aek9f6xhl1zn1puuuot19wqi7.htm
Thanks 🙂 It works.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.