<?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: Query on proc sgplot in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647508#M193806</link>
    <description>&lt;P&gt;Now describe what you mean by "for people arrived to both hotels in all three years"&lt;/P&gt;
&lt;P&gt;There is not way I can see from that data to identify if any particular person arrived at any hotel in any given year.&lt;/P&gt;
&lt;P&gt;So do you mean totals of some sort? That will require some sort of summary and filter likely.&lt;/P&gt;
&lt;P&gt;I might guess that you want to display the total by hotel by year.&amp;nbsp; Scatter plots will not summarize data. You would have to do that prior to plotting the data. And if you mean "people" to be a total of adults, children and babies you will need to sum those prior to plotting as well.&lt;/P&gt;
&lt;P&gt;maybe something like (untested as data step not provided and you only show one "hotel" value so incomplete example)&lt;/P&gt;
&lt;PRE&gt;data temp;
   set hotel.hotel_bookings;
   people = sum(adults,children,babies);
run;
proc summary data=temp nway;
   class hotel country arrival_date_year;
   var people;
   output out =work.plot (drop=_type_ _freq_) sum=;
run;

proc sgplot data=work.plot;
  scatter x=arrival_date_year y=people/ group=hotel datalabel=country;
  title'guest arrived from countries in three years';
  run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And does the Is_cancelled variable have any role in this process?&lt;/P&gt;</description>
    <pubDate>Wed, 13 May 2020 15:44:32 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-05-13T15:44:32Z</dc:date>
    <item>
      <title>Query on proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647455#M193792</link>
      <description>&lt;PRE&gt; proc sgplot data=hotel.Hotel_bookings;
  scatter x=arrival_date_year y=country/ group=hotel;
  title'guest arrived from countries in three years';
  run;&lt;/PRE&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I wanted to find out the guest arrived from various countries ,in three different year years to two hotels. I am not getting the output correctly. Looking for help please!&lt;/P&gt;&lt;P&gt;hotel is my libname&lt;/P&gt;&lt;P&gt;Hotel.bookings is the dataset&lt;/P&gt;&lt;P&gt;arrival_date_year is has from 2015,2016,2017&lt;/P&gt;&lt;P&gt;country - my dataset has various countries inside&lt;/P&gt;&lt;P&gt;hotel- resort hotel and city hotel.&lt;/P&gt;&lt;P&gt;These are the expansion of the code, could anyone please help where i am wrong??&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 13:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647455#M193792</guid>
      <dc:creator>Amali6</dc:creator>
      <dc:date>2020-05-13T13:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Query on proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647468#M193796</link>
      <description>&lt;P&gt;You should show us some examples of what your hotel.hotel_bookings data set actually looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then describe exactly what you expect the output to look like.&lt;/P&gt;
&lt;P&gt;If you mean to do this for individuals then likely this is going to be a very busy chart.&lt;/P&gt;
&lt;P&gt;You may want to summarize before plotting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 14:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647468#M193796</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-13T14:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Query on proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647477#M193802</link>
      <description>&lt;PRE&gt;hotel	is_canceled	lead_time	arrival_date_year	arrival_date_month	arrival_date_week_number	arrival_date_day_of_month	stays_in_weekend_nights	stays_in_week_nights	adults	children	babies	meal	country
Resort Hotel	0	342	2015	July	27	1	0	0	2	0	0	BB	PRT
Resort Hotel	0	737	2015	July	27	1	0	0	2	0	0	BB	PRT
Resort Hotel	0	7	2015	July	27	1	0	1	1	0	0	BB	GBR
Resort Hotel	0	13	2015	July	27	1	0	1	1	0	0	BB	GBR
Resort Hotel	0	14	2015	July	27	1	0	2	2	0	0	BB	GBR
Resort Hotel	0	14	2015	July	27	1	0	2	2	0	0	BB	GBR
Resort Hotel	0	0	2015	July	27	1	0	2	2	0	0	BB	PRT
Resort Hotel	0	9	2015	July	27	1	0	2	2	0	0	FB	PRT
Resort Hotel	1	85	2015	July	27	1	0	3	2	0	0	BB	PRT
Resort Hotel	1	75	2015	July	27	1	0	3	2	0	0	HB	PRT
Resort Hotel	1	23	2015	July	27	1	0	4	2	0	0	BB	PRT
Resort Hotel	0	35	2015	July	27	1	0	4	2	0	0	HB	PRT
Resort Hotel	0	68	2015	July	27	1	0	4	2	0	0	BB	USA
Resort Hotel	0	18	2015	July	27	1	0	4	2	1	0	HB	ESP
Resort Hotel	0	37	2015	July	27	1	0	4	2	0	0	BB	PRT
Resort Hotel	0	68	2015	July	27	1	0	4	2	0	0	BB	IRL
Resort Hotel	0	37	2015	July	27	1	0	4	2	0	0	BB	PRT
Resort Hotel	0	12	2015	July	27	1	0	1	2	0	0	BB	IRL
Resort Hotel	0	0	2015	July	27	1	0	1	2	0	0	BB	FRA
Resort Hotel	0	7	2015	July	27	1	0	4	2	0	0	BB	GBR
Resort Hotel	0	37	2015	July	27	1	1	4	1	0	0	BB	GBR
Resort Hotel	0	72	2015	July	27	1	2	4	2	0	0	BB	PRT
Resort Hotel	0	72	2015	July	27	1	2	4	2	0	0	BB	PRT
Resort Hotel	0	72	2015	July	27	1	2	4	2	0	0	BB	PRT&lt;/PRE&gt;&lt;P&gt;This is the few columns in my dataset , from these how cani show the plots for people arrived to both hotels in all three years from various countries in the dataset?&lt;/P&gt;&lt;P&gt;Please help me to solve this!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 14:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647477#M193802</guid>
      <dc:creator>Amali6</dc:creator>
      <dc:date>2020-05-13T14:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Query on proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647508#M193806</link>
      <description>&lt;P&gt;Now describe what you mean by "for people arrived to both hotels in all three years"&lt;/P&gt;
&lt;P&gt;There is not way I can see from that data to identify if any particular person arrived at any hotel in any given year.&lt;/P&gt;
&lt;P&gt;So do you mean totals of some sort? That will require some sort of summary and filter likely.&lt;/P&gt;
&lt;P&gt;I might guess that you want to display the total by hotel by year.&amp;nbsp; Scatter plots will not summarize data. You would have to do that prior to plotting the data. And if you mean "people" to be a total of adults, children and babies you will need to sum those prior to plotting as well.&lt;/P&gt;
&lt;P&gt;maybe something like (untested as data step not provided and you only show one "hotel" value so incomplete example)&lt;/P&gt;
&lt;PRE&gt;data temp;
   set hotel.hotel_bookings;
   people = sum(adults,children,babies);
run;
proc summary data=temp nway;
   class hotel country arrival_date_year;
   var people;
   output out =work.plot (drop=_type_ _freq_) sum=;
run;

proc sgplot data=work.plot;
  scatter x=arrival_date_year y=people/ group=hotel datalabel=country;
  title'guest arrived from countries in three years';
  run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And does the Is_cancelled variable have any role in this process?&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 15:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647508#M193806</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-13T15:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Query on proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647537#M193814</link>
      <description>&lt;P&gt;Because you have discrete variables, I suggest a bar chart instead of a scatter plot. You can either use a stacked bar chart or a cluster bar chart. The stacked bars are probably better if you have many countries. For more information, see &lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2013/09/07/bar-charts-with-stacked-and-cluster-groups/" target="_self"&gt;"Bar Charts with Stacked and Cluster Groups."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't say how you want the data displayed, so I chose two charts (one for each type of hotel) that shows the number of visitors from each country for each year.&amp;nbsp; If you want the data displayed in some other way, the code can be modified:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data. I use a frequency variable (FREQ), but
   the bar chart will aggregate if the data set contains
   one observation per guest. */
data bookings;
call streaminit(1);
length country $15 hotel $6;
do arrival_date_year = 2015 to 2017;
   do country = "US", "UK", "China", "Japan";
      do hotel = "City", "Resort"; 
          Freq = rand("Poisson", 100);
          output;
      end;
   end;
end;
run;

proc sort data=bookings;
by hotel;
run;

title'Guest arrived from countries in three years';
proc sgplot data=bookings;
  by hotel;
  vbar arrival_date_year / response=Freq group=country 
            groupdisplay=stack seglabel;
  xaxis display=(nolabel);
  yaxis grid;
  run;

proc sgplot data=bookings;
  by hotel;
  vbar arrival_date_year / response=Freq group=country 
            groupdisplay=cluster;
  xaxis display=(nolabel);
  yaxis grid;
  run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 May 2020 17:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647537#M193814</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-05-13T17:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Query on proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647565#M193820</link>
      <description>&lt;P&gt;Thanks for making me clear! Sorry i didnt explain my variables properly.The variable is_canceled contains 0 an 1 where 0 is bookings that are not canceled and 1 is canceled bookings. Hotel variables contains value city hotel and resort hotel.Actually my dataset has more than 1lakhs observations thats why i couldn't post here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, is it possible to show in plots the number of people arrived in three years for both hotels??&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 18:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647565#M193820</guid>
      <dc:creator>Amali6</dc:creator>
      <dc:date>2020-05-13T18:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Query on proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647576#M193825</link>
      <description>&lt;P&gt;Thanks for the solution but i dont understand the data step u provided. As the dataset is already imported into sas then why to create this step here?&lt;/P&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data bookings;
call streaminit(1);
length country $15 hotel $6;
do arrival_date_year = 2015 to 2017;
   do country = "US", "UK", "China", "Japan";
      do hotel = "City", "Resort"; 
          Freq = rand("Poisson", 100);
          output;
      end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 18:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647576#M193825</guid>
      <dc:creator>Amali6</dc:creator>
      <dc:date>2020-05-13T18:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Query on proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647580#M193827</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i tried your code i got the output like this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Amali6_0-1589395464219.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39385i50134D9A173C0049/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Amali6_0-1589395464219.png" alt="Amali6_0-1589395464219.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;May i know the explanation of this line in the code please:&lt;/P&gt;&lt;PRE&gt;output out =work.plot (drop=_type_ _freq_) sum=;&lt;/PRE&gt;&lt;P&gt;Can i use the library i created insted of work library in the code? And i am not clear with this (drop=_type_ _freq_) sum=;&lt;/P&gt;&lt;P&gt;Could you please explain??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 18:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647580#M193827</guid>
      <dc:creator>Amali6</dc:creator>
      <dc:date>2020-05-13T18:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Query on proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647581#M193828</link>
      <description>&lt;P&gt;Because I don't have access to your data and you didn't provide data in a format that I could use.&amp;nbsp; You can ignore the DATA step. It is for me and others who do not have access to your data.&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 18:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-on-proc-sgplot/m-p/647581#M193828</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-05-13T18:51:08Z</dc:date>
    </item>
  </channel>
</rss>

