BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
1 REPLY 1
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 604 views
  • 0 likes
  • 2 in conversation