I figured out the following way to get my data to sum and print exactly the way I want it. However, it is quite inelegant coding and I could use some input on better ways.
Basically I'm using PROC SQL with a CASE statement to summarize my data in a particular way, and then using PROC FORMAT to make sure the data groupings are ordered properly. As I say, the following code works, but it seems pretty clunky.
WHEN missing(ORIG_COST) THEN '.'
WHEN ORIG_COST = 0 THEN '0'
WHEN ORIG_COST BETWEEN 1 AND 4500 THEN '1 - 4,500'
WHEN ORIG_COST BETWEEN 4501 AND 6000 THEN '4,501 - 6,000'
END AS Cost,
GROUP BY Cost ORDER BY put(Cost, $Cost.);
Oh, and I should also note this is just a sample. The reason I need the PROC FORMAT is because there are a lot more ranges in my real data and I end up getting ugly results like '10,001 - 25,000' showing up before '6,001 - 10,000' (for example).
Thanks, dall_null. I appreciate the response, particularly since I did not know about the power of PROC SUMMARY.
Still, I think this doesn't quite help me. My data set has a number of variables that I need to seperate into ranges, output with a specific character field, and print in numeric order. I think the way you describe will require sorting the data for each variable I need to output, which seems about as efficient as my approach.
I guess what would be ideal is if there was some procedure that could assign a label to a variable (like PROC FORMAT) but also assign a value for sorting purposes. If anyone knows of such a thing, I'd love to hear it, but I can stick to what I have as well.