I have the following graph:
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;
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.