Desktop productivity for business analysts and programmers

ordered character ranges with gplot

Reply
N/A
Posts: 0

ordered character ranges with gplot

This is irritatingly simple, but I can't get it.

I have a continuous variable (age) that I have created categorical ranges for.
Partial follows:

IF REALAGE <= 3 THEN AGERANGE = "0-3";
ELSE IF 3 <= REALAGE AND REALAGE <= 5 THEN AGERANGE = "3-5";
ELSE IF 5 <= REALAGE AND REALAGE <= 8 THEN AGERANGE = "5-8" ;
ELSE IF 8 <= REALAGE AND REALAGE <= 11 THEN AGERANGE = "8-11";
ELSE IF 11 <= REALAGE AND REALAGE <= 14 THEN AGERANGE = "11-14" ;

I am plotting a single value per agerange with gplot in SASEG. I WANT the horizontal axis to read as it should (i.e. 0-3, 3-5, 5-8, 8-11, 11-14) instead it plots it out as (i.e. 0-3, 11-14, 3-5, 5-8, 8-11).

I have tried inserting proc format with the insert code option, no good.

Thoughts?
SAS Super FREQ
Posts: 8,717

Re: ordered character ranges with gplot

Hi,
There are several different ways to do this. The easiest might be to insert a leading space before the single digit ranges. [pre]
IF REALAGE <= 3 THEN AGERANGE = " 0-3";
ELSE IF 3 <= REALAGE AND REALAGE <= 5 THEN AGERANGE = " 3-5";
ELSE IF 5 <= REALAGE AND REALAGE <= 8 THEN AGERANGE = " 5-8" ;
ELSE IF 8 <= REALAGE AND REALAGE <= 11 THEN AGERANGE = " 8-11";
ELSE IF 11 <= REALAGE AND REALAGE <= 14 THEN AGERANGE = "11-14" ;
[/pre]
you may also need a length statement so the AGERANGE variable does not get truncated:
[pre]
length agerange $5;[/pre]
For more about the other ways to do ordering, you could contact Tech Support.
cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 102 views
  • 0 likes
  • 2 in conversation