BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello

I'm doing an evaluation of SAS Enterprise Guide, to test if it can be used to teach Students and I ran into a problem when I try to replace a range of values.
The problem consists in both Versions EG3.0 and Learning Edition EG4.1. Perheps Im just doing it the wrong way, but I can't find a solution to it.

I've got an column "Age", which holds the very precise age of Patients, like (14.753424658). Now I have to make a new group column. Patients between the age 5 to 10 get a new value "Child", age 10 to 15 "Teenagers" and so on.
The code that the EG creates looks like this:

(CASE
WHEN 5 <= IMPW9568.Age AND IMPW9568.Age <= 10 THEN 'Child'
WHEN 10 <= IMPW9568.Age AND IMPW9568.Age <= 15 THEN 'Teen'
...
ELSE 'NA' END) AS Age_Group

As you may see the upper limit and the lower limit are overlapping <= 10 is the same as 10<=
But if I change my boundaries, so that they dont overlap:

(CASE
WHEN 5 <= IMPW9568.Age AND IMPW9568.Age <= 9 THEN 'Child'
WHEN 10 <= IMPW9568.Age AND IMPW9568.Age <= 14 THEN 'Teen'
...
ELSE 'NA' END) AS Age_Group

Then I'm getting NA (missings), since all the people between 9 and 10 (9.35367847) are left out.

Perheps it's not a bug, but a feature.
But its a problem for me. I could of course use very precise limits, like:
CASE
WHEN 5 <= IMPW9568.Age AND IMPW9568.Age <= 9.999999999 THEN 'Child'
WHEN 10 <= IMPW9568.Age AND IMPW9568.Age <= 14.999999999 THEN 'Teen'
...
ELSE 'NA' END) AS Age_Group

But perheps there is a better alternative?

SAS Analyst for example has an extra option to chose between a "<= x <" and "< x <=" logic. But a "<=" on both sides, as the EG creates it, just doesn't make much sense to me.

Thank you

Edit:
Perfect would be something like that:

(CASE
WHEN 5 <= IMPW9568.Age AND IMPW9568.Age < 10 THEN 'Child'
WHEN 10 <= IMPW9568.Age AND IMPW9568.Age < 15 THEN 'Teen'
...
ELSE 'NA' END) AS Age_Group

But creatable with EG.


Message was edited by: Tillmann Babik at Mar 26, 2007 6:03 AM


Message was edited by: Tillmann Babik at Mar 26, 2007 6:36 AM
Message was edited by: Tillmann Babik at Mar 26, 2007 6:40 AM
3 REPLIES 3
rab24
Calcite | Level 5
I assume you are using the Create Query function in EG to replace values. That function gives "<=x<=" because it allows you to see every exact value within your dataset.

If you want to have the code set up to handle additional updates, complete the 'Replace Values' information and then go back to the 'General' Tab where you can change the EG generated code to the code you actually want (<=x<).
deleted_user
Not applicable
Hi Rab24

Yes I'm working with the create query function. Actually the only other way I would know is to create a format for it.

But your suggestion worked, I must have overlooked that Im able to change the expression afterwards.

Thank you
prholland
Fluorite | Level 6
Your statement:
"the upper limit and the lower limit are overlapping <= 10 is the same as 10<="

is not true as 10 will be captured by <=10 and not by 10<=.

I don't think you need to change your original code to cope with very precise ages!

..........Phil

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
  • 3 replies
  • 611 views
  • 0 likes
  • 3 in conversation