<?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 Limit Lines to Top 5 Using SGPLOT in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801383#M22667</link>
    <description>&lt;P&gt;Hey everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First time posting on here, as I am new to SAS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My dataset is about toy sales for different facilities by country.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to plot the data using SGPLOT but want to limit the lines on the graph to the top 5 facilities instead of including all 30 countries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=mis543.toys order=freq;&lt;BR /&gt;tables facilitycountry;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;(The above code shows me sales by country in descending order)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;title "Toys Sold by Location in 2017";&lt;BR /&gt;proc sgplot data=mis543.toys;&lt;BR /&gt;series x=transactionmonth y=productpriceactual / group=facilitycountry;&lt;BR /&gt;run;&lt;BR /&gt;title;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPLOT.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69351iAAA532A04AE26C40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGPLOT.PNG" alt="SGPLOT.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is the graph; which IS what I want... But only need the top 5 countries, not all of them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Mar 2022 16:15:41 GMT</pubDate>
    <dc:creator>mccusker1818</dc:creator>
    <dc:date>2022-03-10T16:15:41Z</dc:date>
    <item>
      <title>Limit Lines to Top 5 Using SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801383#M22667</link>
      <description>&lt;P&gt;Hey everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First time posting on here, as I am new to SAS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My dataset is about toy sales for different facilities by country.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to plot the data using SGPLOT but want to limit the lines on the graph to the top 5 facilities instead of including all 30 countries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=mis543.toys order=freq;&lt;BR /&gt;tables facilitycountry;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;(The above code shows me sales by country in descending order)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;title "Toys Sold by Location in 2017";&lt;BR /&gt;proc sgplot data=mis543.toys;&lt;BR /&gt;series x=transactionmonth y=productpriceactual / group=facilitycountry;&lt;BR /&gt;run;&lt;BR /&gt;title;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPLOT.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69351iAAA532A04AE26C40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGPLOT.PNG" alt="SGPLOT.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is the graph; which IS what I want... But only need the top 5 countries, not all of them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 16:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801383#M22667</guid>
      <dc:creator>mccusker1818</dc:creator>
      <dc:date>2022-03-10T16:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Limit Lines to Top 5 Using SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801390#M22668</link>
      <description>&lt;P&gt;You will have to filter the data somehow.&lt;/P&gt;
&lt;P&gt;If you want that done "automagicly" by the code then you write code to identify/select the records you want and either add a variable to your plot data set to indicate the records to use for plotting use that information to write the code for Prog Sgplot or combination.&lt;/P&gt;
&lt;P&gt;Or you identify manually the values of your group variable to plot and put them in the code. Such as use that Proc Freq output to get the values and write something like&lt;/P&gt;
&lt;PRE&gt;title "Toys Sold by Location in 2017";
proc sgplot data=mis543.toys;
   where facilitycountry in ("firstname" "secondname" "third" "fourth" "fifth");
   series x=transactionmonth y=productpriceactual / group=facilitycountry;
run;
title;&lt;/PRE&gt;
&lt;P&gt;The Where statement is usable in almost every procedure so isn't listed in each proc. It is used to filter data.&lt;/P&gt;
&lt;P&gt;If you have not seen the IN operator it is like writing a bunch of&lt;/P&gt;
&lt;PRE&gt;If Var=1 or Var=2 or Var=3 or var=4 or var=77;

equivalent where
where var in (1 2 3 4 77);&lt;/PRE&gt;
&lt;P&gt;I assumed your "facilitycountry" is text but if it is numeric just use the number values.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 16:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801390#M22668</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-10T16:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: Limit Lines to Top 5 Using SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801397#M22669</link>
      <description>So what if I needed to predict the following 3 months sales for each location using PROC FORECAST?</description>
      <pubDate>Thu, 10 Mar 2022 17:07:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801397#M22669</guid>
      <dc:creator>mccusker1818</dc:creator>
      <dc:date>2022-03-10T17:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Limit Lines to Top 5 Using SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801402#M22670</link>
      <description>&lt;P&gt;Not a user of Proc Forecast.&lt;/P&gt;
&lt;P&gt;Likely the way would be to sort the data by location and then us BY location to get a forecast for each location.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404151"&gt;@mccusker1818&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;So what if I needed to predict the following 3 months sales for each location using PROC FORECAST?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 17:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801402#M22670</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-10T17:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Limit Lines to Top 5 Using SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801567#M22671</link>
      <description>So would I use PROC SORT to sort the data by location?</description>
      <pubDate>Fri, 11 Mar 2022 02:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Limit-Lines-to-Top-5-Using-SGPLOT/m-p/801567#M22671</guid>
      <dc:creator>mccusker1818</dc:creator>
      <dc:date>2022-03-11T02:11:06Z</dc:date>
    </item>
  </channel>
</rss>

