BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
PeroGti
Fluorite | Level 6

Dear SAS experts,

I have a problem with the residual graph, I need to get this graph bellow in the picture;

Residual values for each country and connect them with line between years 

does someone know the code for residuals plots with multiple countries and connected with line

PeroGti_0-1683223518205.png

Thank you in advance.

best regards,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You named the output of the data set with the residuals (out=residual).

 

Then for the plotting step you use the original data set (data=sas_project), not the new one created with the residuals. Review the code I've posted and compare for the differences. 

 

 

View solution in original post

9 REPLIES 9
PaigeMiller
Diamond | Level 26

PROC SGPLOT can do this. Example

--
Paige Miller
Reeza
Super User
Show the code used to create the model and output.
Ideally, sample data so we could replicate would be ideal.

In general, this is easy enough to do using SGPLOT and the output dataset from the regression. Guessing, something like the following;

proc sgplot data=residuals;
series x=godina y=residual / group=drzava markers;
run;
PeroGti
Fluorite | Level 6

Hello,

I'm using this codes to create the model and output;

/*SAS kod*/
Proc means data=WORK.SAS_project;
var 'Housing_Loans_[millions]_y'n GDP_per_capita_x Active_population_x wages_Eurostat_x;
by drzava;
run;

/*SAS kod*/
data WORK.SAS_project; set WORK.SAS_project;
'Housing_Loans_[millions]_y'n=log('Housing_Loans_[millions]_y'n);
Active_population_x=log(Active_population_x);
wages_Eurostat_x=log(wages_Eurostat_x);
GDP_per_capita_x=log(GDP_per_capita_x);
run;

/*SAS code*/
title"Model fiksnih efekata";
proc panel data=WORK.SAS_project;
id drzava Year;
model 'Housing_Loans_[millions]_y'n= Active_population_x GDP_per_capita_x wages_Eurostat_x /fixone printfixed;
run;

now I need to create that graph for residual values on the y axis for each country, if would be easier to send a file maybe?

thank you in andvance

best regards

Reeza
Super User

Add the following to your proc panel.

 

output out=residuals r=residual;

And then try the code I posted replacing 'godina' with year.

PeroGti
Fluorite | Level 6

hello,

I have tried the code and the next error appears:

proc sgplot data=WORK.SAS_project;
series x=Year y=residual / group=drzava markers;
ERROR: Variable RESIDUAL not found.
run;

 

do You know why is something wrong in the code?

PeroGti
Fluorite | Level 6

this is the code that I write:

proc panel data=WORK.SAS_project;
id drzava Year;
model 'Housing_Loans_[millions]_y'n= Active_population_x GDP_per_capita_x wages_Eurostat_x /fixone printfixed;
output out=residual r=residual;
run;
proc sgplot data=WORK.SAS_project;
series x=Year y=residual / group=drzava markers;
run;

PeroGti
Fluorite | Level 6

the closest results corresponding to the graph above I get with next code:

/*SAS code*/
title"Model fiksnih efekata";
symbol value=circle;
proc reg data=WORK.SAS_project;
model Year= Active_population_x GDP_per_capita_x wages_Eurostat_x ;
plot residual. * predicted.;
by drzava;
run;

but as you can see in the picture bellow the results I get is for each country separately (I need all together in one graph) and additionally I don't know to connect the dots with line in this code

if someone knows please help

 

 

PeroGti_0-1683230873765.png

 

 

Reeza
Super User

You named the output of the data set with the residuals (out=residual).

 

Then for the plotting step you use the original data set (data=sas_project), not the new one created with the residuals. Review the code I've posted and compare for the differences. 

 

 

PeroGti
Fluorite | Level 6
thank you very much 🙂

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 2095 views
  • 3 likes
  • 3 in conversation