BookmarkSubscribeRSS Feed
laneylaners
Obsidian | Level 7

I have the following graph:

 

lines.JPG

 

i want only the data points that are above and below those two lines (arrows shown to indicate).

 

i want to be able to use proc print to show these data points that fall above or below those lines.

 

i am having a hard time figuring out how to do this.  i have defined the lines in the data set, and then defined them in sgplot so they show up on the graph.  is there any way i can take the 'slope' of the line and apply it to a where statement in proc print so i get only those values above/below the lines?

 

data work.wr_wp_combined_ELG;

set work.wr_wp_combined_ELG end=end;

by carnum;

if _n_=1 then do;

lx=0;

ly=0;

lj=0;

lk=0.4;

end;

if end then do;

lx=3;

ly=3;

lj=3;

lk=3.4;

end;

run;

title1 "Barber S2-C";

title2 "B-Truck Wedge Rise vs Max Column Wear Depth";

proc sgplot data=work.wr_wp_combined_ELG noautolegend;

scatter x=wp_max_b y=WR_truck_B / datalabel=carnum datalabelattrs=(size=10) MARKERATTRS=(SIZE=2);

series x=lx y=ly / lineattrs=(color=red) ;

series x=lj y=lk / lineattrs=(color=red);

xaxis values=(0 to 3 by .2) label="Maximum Wear Depth" grid;

yaxis values=(0 to 3 by .2) label="Avg Wedge Rise" grid;

run;

title;

 

proc print data=work.wr_wp_combined_ELG noobs;

var carnum inspection_date wp_max_b WR_truck_B;

******some sort of where statement here???***********

title "All Car Numbers. Might need to do a manual analysis of those that fit criteria";

run;

title;

1 REPLY 1
ballardw
Super User

The generic form would be:

 

Where y-value < (lower bound) or y-value > (upper bound);

 

lower bound and upper bound would be expressed as a function of the X variable, the ever populat mx + b with m the slope b the intersept.

 

where  WR_truck_B < (m*wp_max_b +lowerb)    or WR_truck_B >(m*wp_max_b + upperb);

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!

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.

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
  • 1151 views
  • 0 likes
  • 2 in conversation