BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
YangYY
Quartz | Level 8

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.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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:

 

 

Udklip.PNG

View solution in original post

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

Can you provide some example of what your data looks like? Makes it much easier to provide a usable code answer 🙂

YangYY
Quartz | Level 8

Of course.

My data is attached and that is my latest result . Thank you for your reply!

PeterClemmensen
Tourmaline | Level 20

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:

 

 

Udklip.PNG

YangYY
Quartz | Level 8

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?

ballardw
Super User

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.

YangYY
Quartz | Level 8

No. The whole variable of continent of all observations are missing. Only the variable name "continent" does show.

 

But thank you for your reply!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 767 views
  • 0 likes
  • 3 in conversation