Starbucks
Starbucks

Reputation: 1568

SAS: Using WHERE / IF Statement in SGPlot

Good afternoon,

I would like to define my parameters in my plot as opposed to generating a plot with all values.

For example, I want to show only the sale price of the data not exceeding $400,000. This syntax is not correct, but this is my attempt at it. Should I use the if, by, or where statement in this matter? Thank you!

proc sgplot data=mydata; 
loess x = FirstFlrSF  y = saleprice / group= OverallQual;
reg x = FirstFlrSF y = saleprice;
where saleprice =< 400000;
title "First Floor SF vs sales price"; run;

Upvotes: 1

Views: 7406

Answers (2)

Reeza
Reeza

Reputation: 21274

IF's don't work in PROCS, but WHERE's do, however you have the comparison operator specified incorrectly. It's <= instead of =<. I always remember the order by saying it out loud, less than or equal to.

proc sgplot data=sashelp.class;
scatter x=height y=weight;
where age <= 15;
run;quit;

Upvotes: 2

Starbucks
Starbucks

Reputation: 1568

The placement of the where statement was not in the correct line.

proc sgplot data=mydata (where =(saleprice <= 400000)); 
loess x = FirstFlrSF  y = saleprice / group= OverallQual;
reg x = FirstFlrSF y = saleprice;
title "First Floor SF vs sales price"; run;

Upvotes: -1

Related Questions