SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tecla1
Quartz | Level 8

Hi to all,

 

i need to take observation that are not stricly > or < of a number but are nearest of a number … which function i need to use?

Many tnks.

 

Tecla

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

OK, this perhaps then ?

 

proc sql;
    CREATE TABLE want AS
    SELECT *
    FROM have
    HAVING abs(x-75)=min(abs(x-75));
quit;

View solution in original post

5 REPLIES 5
gamotte
Rhodochrosite | Level 12

Hello,

 

Something like this ?

 

%let precision=1.0e-6;

data have;
input x y;
cards;
1 1.0001
1 0.9999
1 1.0000001
1 0.9999999
;
run;

proc sql;
    CREATE TABLE equals AS
    SELECT *
    FROM have
    WHERE abs(x-y)<&precision.;
quit;
Tecla1
Quartz | Level 8

Hi Tnks for your kindly reply….

 

non so much because i don't have a dimension for the around , the around can be bigger but the only i have ….

 

Example:

 

If I find an around of 75 and I have only one more observation , like 20... my result will be 20....

 

I'm clear ? excuse for my english…

 

Tecla

Shmuel
Garnet | Level 18

You can compute the difference between the two values as absolute percentage of of the lowest/highest value

and check vs some logical limit/ 

gamotte
Rhodochrosite | Level 12

OK, this perhaps then ?

 

proc sql;
    CREATE TABLE want AS
    SELECT *
    FROM have
    HAVING abs(x-75)=min(abs(x-75));
quit;
Tecla1
Quartz | Level 8

TNKS SO MUCH !!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2196 views
  • 0 likes
  • 3 in conversation