BookmarkSubscribeRSS Feed
Uddin
Fluorite | Level 6

Hi,

I have 5-set data (2015-2019), and I need to make it into long data set. I made it (combined) and then I list the happiness ranks and happiness scores for Australia and the countries that were in the top 5 or the bottom 5 in 2019.

For Australia:

Uddin_3-1655278657597.png

Top 5:

Uddin_4-1655278699057.png

Bottom 5:

Uddin_5-1655278730120.png

Now I want to create graphs for the change in happiness index over time for the two groupings identified in above: the top 5 plus Australia and then the bottom 5.  In addition to this, I want to show all 11countries on the same graph.

Looking for your kind response.

2 REPLIES 2
Kurt_Bremser
Super User

What have you done so far?

 

Please provide example data in usable form (data step(s) with datalines). We cannot use pictures for developing and testing.

Post your data step code into a window opened with the "little running man" button.

Uddin
Fluorite | Level 6

Here is the data:

Top Country:

Country, Happiness_rank, Happiness_score, Year

Finland, 1, 7.769, 2019

Denmark, 2, 7.6, 2019

Norway, 3, 7.554, 2019

Iceland, 4, 7.494, 2019

Netherlands, 5, 7.488, 2019

Finland, 2, 7.369, 2018

Denmark, 3, 7.4, 2018

Norway, 1, 7.254, 2018

Iceland, 6, 7.394, 2018

Netherlands, 5, 7.188, 2018

Finland, 1, 7.369, 2017

Denmark, 4, 7.4, 2017

Norway, 1, 7.254, 2017

Iceland, 3, 7.394, 2017

Netherlands, 5, 7.188, 2017

 

Bottom 5:

Country, Happiness_rank, Happiness_score, Year

South Sudan, 156, 2.853, 2019

Central Africa, 155, 3.083, 2019

Afghanistan, 154, 3.203, 2019

Tanzania, 153, 3.231, 2019

Rwanda, 152, 3.334, 2019

South Sudan, 156, 2.653, 2018

Central Africa, 155, 3.183, 2018

Afghanistan, 154, 3.223, 2018

Tanzania, 153, 3.261, 2018

Rwanda, 152, 3.364, 2018

South Sudan, 156, 2.753, 2017

Central Africa, 155, 3.183, 2017

Afghanistan, 154, 3.293, 2017

Tanzania, 153, 3.331, 2017

Rwanda, 152, 3.344, 2017

 

Australia

Country, Happiness_rank, Happiness_score, Year

Australia, 11, 7.228, 2019

Australia, 10, 7.128, 2018

Australia, 12, 7.628, 2017

 

 

data have;
set combined;
if Happiness_score <=7.488 then group=top;
else if Happiness_score >=3.334 then group=bottom;
else group=Australia;
run;
title 'Changes in happiness score by group (top and bottom) over time including Australia';
proc sgplot data=combined;
series x=year y=Happiness_score /group = Hapiness_score;
yaxis grid minor minorgrid min=0;
xaxis label='Year';
run;

Looking for your kind response

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 325 views
  • 0 likes
  • 2 in conversation