In: Statistics and Probability
From the data set myclass.restaurantratings, create - a scatter digram with a regression line between score and price (use REG statement in PROC SGPLOT) Add a title to the scatter diagram and provide a brief discussion on the relationship between the two variables.
code in sas to get scatterplot only:
PROC SGPLOT DATA=myclass.restaurantratings;
SCATTER X=SCORE Y=PRICE;
TITLE'restaurantratings scatterplot';
RUN;
Run below code to get scatter digram with a regression line :
You can use the OUTEST= option or the ODS OUPUT statements to save the parameter estimates to a SAS data set. In the following example, the ODS OUTPUT statement saves the ParameterEstimates table to the PE data set:
ods graphics off; proc reg data=myclass.restaurantratings; ods output ParameterEstimates=PE; run; Step 2: Create macro variables In the PE data set, the ESTIMATE variable contains the parameter estimates. The first row contains the estimate for the intercept term; the second row contains the estimate for the slope. The following DATA step saves these into macro variables:
|
PROC SGPLOT DATA=myclass.restaurantratings noautolegend;
TITLE'regression line with slope and y intercept;
REG Y=PRICE X=SCORE;
INSET "Intercept= &Int" "slope =&slope”/ border title=”Parameter Estimates” position=topleft;
Run;