I have variables country, continent and the populations for every year of 1800-2100. I have got the total size of each continent for different years. Now I need to use PROC SGPLOT and SERIES statement to plot the population growth of each continent since 1800.
But I have no idea how to start. I might need to calculate the population difference first?
Anyone could help?? Anything will be appreciated.
This should get you going 🙂 Feel free to ask if you have questions
title "Population Growth By Continent";
proc sgplot data=pop_summary;
series x=year y=sum / group=continent;
keylegend / position=nw location=inside across=1;
run;
title;
Result:
Can you provide some example of what your data looks like? Makes it much easier to provide a usable code answer 🙂
Of course.
My data is attached and that is my latest result . Thank you for your reply!
This should get you going 🙂 Feel free to ask if you have questions
title "Population Growth By Continent";
proc sgplot data=pop_summary;
series x=year y=sum / group=continent;
keylegend / position=nw location=inside across=1;
run;
title;
Result:
Thank you so much!!
I got another question about SAS studio.
My code is
proc summary data=assign02.summary sum;
by continent;
var year1800-year2100;
output out=assign02.pop_summary sum=;
run;
proc transpose data=assign02.pop_summary out=assign02.pop_summary2(rename=(_NAME_=year) rename=(col1='total population'n));
var year1800-year2100;
by continent;
run;
But I don't know why, the continent are missing after proc transpose.
Is it because of my code got mistakes?
Are you referring to a single observation without continent? That has very large values for the year values?
That, which would have _type_=0 is the data set total summary. If you do not use NWAY or one of the other options the proc summary will create a summary of all combinations of your CLASS variables, including one with all values. Print your assign02.pop_summary dataset. I suspect you will find 7 rows of data, your 6 continents plus the overall total.
If that is the case then try adding NWAY to the proc summary. That will only have the continent values. The option makes the output show only the combinations of all class variables with non-missing values.
No. The whole variable of continent of all observations are missing. Only the variable name "continent" does show.
But thank you for your reply!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.