<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating a graph based on group in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/819007#M34706</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the solution I found:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;PROC SQL;
CREATE TABLE Top_countries as
SELECT * 
FROM work.combined
WHERE (Country like 'Finland') or (Country like 'Denmark') or (Country like 'Norway') or (Country like 'Iceland') or (Country like 'Netherlands') or (Country like 'Australia');
quit;

title 'Changes in happiness_score by top 5 countries plus Australia over time';
proc sgplot data=Top_countries;
   series x=year y=Happiness_score /group = country;
   run;
   title;

PROC SQL;
CREATE TABLE Bottom_countries as
SELECT * 
FROM work.combined
WHERE (Country like 'South Sudan') or (Country like 'Central African') or (Country like 'Afghanistan') or (Country like 'Tanzania') or (Country like 'Rwanda');
quit;

title 'Changes in happiness_score by bottom 5 countries over time';
proc sgplot data=Bottom_countries;
   series x=year y=Happiness_score /group = country;
   run;
   title;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks everybody for your kind support&lt;/P&gt;</description>
    <pubDate>Sun, 19 Jun 2022 04:57:39 GMT</pubDate>
    <dc:creator>Uddin</dc:creator>
    <dc:date>2022-06-19T04:57:39Z</dc:date>
    <item>
      <title>Creating a graph based on group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/818619#M34671</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have 3-set data (2017-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.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Top Country:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Country, Happiness_rank, Happiness_score, Year&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Finland, 1, 7.769, 2019&lt;/P&gt;&lt;P&gt;Denmark, 2, 7.6, 2019&lt;/P&gt;&lt;P&gt;Norway, 3, 7.554, 2019&lt;/P&gt;&lt;P&gt;Iceland, 4, 7.494, 2019&lt;/P&gt;&lt;P&gt;Netherlands, 5, 7.488, 2019&lt;/P&gt;&lt;P&gt;Finland, 2, 7.369, 2018&lt;/P&gt;&lt;P&gt;Denmark, 3, 7.4, 2018&lt;/P&gt;&lt;P&gt;Norway, 1, 7.254, 2018&lt;/P&gt;&lt;P&gt;Iceland, 6, 7.394, 2018&lt;/P&gt;&lt;P&gt;Netherlands, 5, 7.188, 2018&lt;/P&gt;&lt;P&gt;Finland, 1, 7.369, 2017&lt;/P&gt;&lt;P&gt;Denmark, 4, 7.4, 2017&lt;/P&gt;&lt;P&gt;Norway, 1, 7.254, 2017&lt;/P&gt;&lt;P&gt;Iceland, 3, 7.394, 2017&lt;/P&gt;&lt;P&gt;Netherlands, 5, 7.188, 2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Bottom 5:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Country, Happiness_rank, Happiness_score, Year&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;South Sudan, 156, 2.853, 2019&lt;/P&gt;&lt;P&gt;Central Africa, 155, 3.083, 2019&lt;/P&gt;&lt;P&gt;Afghanistan, 154, 3.203, 2019&lt;/P&gt;&lt;P&gt;Tanzania, 153, 3.231, 2019&lt;/P&gt;&lt;P&gt;Rwanda, 152, 3.334, 2019&lt;/P&gt;&lt;P&gt;South Sudan, 156, 2.653, 2018&lt;/P&gt;&lt;P&gt;Central Africa, 155, 3.183, 2018&lt;/P&gt;&lt;P&gt;Afghanistan, 154, 3.223, 2018&lt;/P&gt;&lt;P&gt;Tanzania, 153, 3.261, 2018&lt;/P&gt;&lt;P&gt;Rwanda, 152, 3.364, 2018&lt;/P&gt;&lt;P&gt;South Sudan, 156, 2.753, 2017&lt;/P&gt;&lt;P&gt;Central Africa, 155, 3.183, 2017&lt;/P&gt;&lt;P&gt;Afghanistan, 154, 3.293, 2017&lt;/P&gt;&lt;P&gt;Tanzania, 153, 3.331, 2017&lt;/P&gt;&lt;P&gt;Rwanda, 152, 3.344, 2017&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Australia&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Country, Happiness_rank, Happiness_score, Year&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Australia, 11, 7.228, 2019&lt;/P&gt;&lt;P&gt;Australia, 10, 7.128, 2018&lt;/P&gt;&lt;P&gt;Australia, 12, 7.628, 2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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. &amp;nbsp;In addition to this, I want to showall11countriesonthesame graph.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
set combined;
if Happiness_score &amp;lt;=7.488 then group=top;
else if Happiness_score &amp;gt;=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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you please help me in this regard. Would be highly appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 16:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/818619#M34671</guid>
      <dc:creator>Uddin</dc:creator>
      <dc:date>2022-06-16T16:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a graph based on group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/818626#M34672</link>
      <description>&lt;P&gt;I think if you want group to be a character variable, then you would need to wrap the text in quotes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 16:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/818626#M34672</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-16T16:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a graph based on group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/818654#M34675</link>
      <description>&lt;P&gt;Your code has numerous errors. You are attempting to use variables Top, Bottom and Australia which do not appear in your example data. IF it ran you would assign Australia to either top or bottom group as your last "else" never executes.&lt;/P&gt;
&lt;P&gt;And the direction of your comparisons places the lowest scores in the Top category and the range comparison you use sets some countries as both "top" and "bottom". So that whole logic is flaky.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you using "group=Hapiness_score"? That is going to attempt to create a separate "group" for each of your Y variables (if you spell the name correctly. As shown I expect an error of a variable not found.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will make a graph with a separate line for each country.&lt;/P&gt;
&lt;P&gt;You need to tell use how the Top, Bottom or Australia are intended to be displayed on the graph. Different color? Different line? In the legend?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data combined;
   infile datalines dlmstr=', ';
   input Country :$15. Happiness_rank Happiness_score Year;
   length Display $ 10;
datalines;
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
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, 11, 7.228, 2019
Australia, 10, 7.128, 2018
Australia, 12, 7.628, 2017
; 


proc sgplot data=combined;
   series x=year y=Happiness_score /group = country ;
   yaxis grid minor minorgrid min=0;
   xaxis label='Year' values=(2017, 2018, 2019);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do want 11 separate series? Then the Group variable would be the Country.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 17:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/818654#M34675</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-16T17:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a graph based on group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/819006#M34705</link>
      <description>Hi Ballardw,&lt;BR /&gt;&lt;BR /&gt;Thank you so much for your kind support. Kind Regards</description>
      <pubDate>Sun, 19 Jun 2022 04:55:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/819006#M34705</guid>
      <dc:creator>Uddin</dc:creator>
      <dc:date>2022-06-19T04:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a graph based on group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/819007#M34706</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the solution I found:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;PROC SQL;
CREATE TABLE Top_countries as
SELECT * 
FROM work.combined
WHERE (Country like 'Finland') or (Country like 'Denmark') or (Country like 'Norway') or (Country like 'Iceland') or (Country like 'Netherlands') or (Country like 'Australia');
quit;

title 'Changes in happiness_score by top 5 countries plus Australia over time';
proc sgplot data=Top_countries;
   series x=year y=Happiness_score /group = country;
   run;
   title;

PROC SQL;
CREATE TABLE Bottom_countries as
SELECT * 
FROM work.combined
WHERE (Country like 'South Sudan') or (Country like 'Central African') or (Country like 'Afghanistan') or (Country like 'Tanzania') or (Country like 'Rwanda');
quit;

title 'Changes in happiness_score by bottom 5 countries over time';
proc sgplot data=Bottom_countries;
   series x=year y=Happiness_score /group = country;
   run;
   title;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks everybody for your kind support&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jun 2022 04:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-graph-based-on-group/m-p/819007#M34706</guid>
      <dc:creator>Uddin</dc:creator>
      <dc:date>2022-06-19T04:57:39Z</dc:date>
    </item>
  </channel>
</rss>

