Hi - is there a way to group observations together, i.e. if fruit is variable and i want to group apple and orange as Group 1 to show in output report?
This is what I got now:
Example of data:
Fruit
Apple
Orange
Grapes
Banana
proc report data=final;
columns fruit n;
define fruit/group;
define n /'Count';
rbreak after / summarize;
run;
I think you would need a column in your final dataset that contains the grouping information you are looking to group by in the proc report.
CATEGORY |
FRUIT | COUNT |
Group 1 | Apple |
10 |
Group 1 | Orange | 20 |
Group 2 | Grapes | 15 |
Group 2 | Banana | 5 |
Then you could define CATEGORY as a group variable.
Hi:
Here's an example using SASHELP.CLASS. Suppose you want to put the students into 2 categories -- Yes or No -- are they eligible for Driver's Ed based on their age. You can do that with a user defined format:
Now the user-defined format is just the beginning. It only defines how the ages get broken up into categories. Now the format needs to be used. This is the output I want to create:
Notice that I have a sub-category of M and F for the male and female students and I'm getting a count of each gender within each age category. I've also added subtotals of count and a grand total for all students at the bottom of the report.
Here's the PROC REPORT code that does everything in one step. Since age is a numeric variable, I wanted to make a helper column to hold the category value and the longer text on the break lines. That was all accomplished in the COMPUTE block for AGECAT, my helper variable:
Hope this helps point you toward one possible solution with PROC REPORT.
Cynthia
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.