<?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: Change the x-axis order in SGPLOT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/369043#M88044</link>
    <description>&lt;P&gt;Thanks Reeza,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I agree that this is the fastest solution!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jun 2017 08:08:24 GMT</pubDate>
    <dc:creator>Chung-Li</dc:creator>
    <dc:date>2017-06-21T08:08:24Z</dc:date>
    <item>
      <title>Change the x-axis order in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/367577#M87547</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data contains patients' ID (idd) and charateristic of that patient (TroughHour) as follows:&lt;/P&gt;&lt;PRE&gt;                                                          Trough
                                          Obs     idd      Hour

                                            1    10002       1
                                            2    10003      23
                                            3    10005       2
                                            4    10006       2
                                            5    10007       4
                                            6    10008       0
                                            7    10009       4
                                            8    10010       3
                                            9    10011       0
                                           10    10012      22
                                           11    10013       4
                                           12    10014       2
                                           13    10015       4
                                           14    10017       2
                                           15    10018       4
                                           16    10023       4
                                           17    10024      22
                                           18    10025       2
                                           19    10026       3
                                           20    10027       0
                                           21    10028      22
                                           22    10029      22
                                           23    10030       3
                                           24    10033       3
                                           25    10034       5
                                           26    10035       3
                                           27    10036      23
                                           28    10037       4
                                           29    10038       1
                                           30    10040      23
                                           31    10041      23
                                           32    10042      23
                                           33    10044       4
                                            .       .        .
                                            .       .        .
                                            .       .        .&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is to draw the frequency or count percentage over the variable "TroughHour".&lt;/P&gt;&lt;P&gt;When we want to draw this, SGPLOT is a very poweful tool, so I use it to do so:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SGPLOT DATA=Have;
	HISTOGRAM TroughHour;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The result goes like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG title="SGPlot1.png" alt="SGPlot1.png" src="https://communities.sas.com/t5/image/serverpage/image-id/9447iAA71CBC59C70C558/image-size/medium?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Though it does show the percentage,&amp;nbsp;the presentation isn't&amp;nbsp;what I&amp;nbsp;expected exactly.&lt;/P&gt;&lt;P&gt;#1 The range isn't right: I only want to show TroughHour= 22, 23, 0, 1, 2, 3, 4, and 5, but it shows from 0 to 23.&lt;/P&gt;&lt;P&gt;#2 The order isn't correct either: I want it to be presented in the order of 22, 23, 0, 1, 2, 3, 4, 5, but now its order is 0, 1, ..., 23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While searching for some useful information by myself, hope you guys can kindly give me a hand.&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 02:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/367577#M87547</guid>
      <dc:creator>Chung-Li</dc:creator>
      <dc:date>2017-06-16T02:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Change the x-axis order in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/367582#M87548</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sgplot data=HAVE;
  vbar HOUR;
  xaxis values=(22,23,0,1,2,3,4,5) ;
  format HOUR z2.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG title="aaa1.PNG" alt="aaa1.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/9450i2D6EABFAC253C000/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 02:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/367582#M87548</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-06-16T02:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Change the x-axis order in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/367587#M87549</link>
      <description>&lt;P&gt;Oh you want percentages.&lt;/P&gt;
&lt;P&gt;If you want no&amp;nbsp;intermediate table (but why not?) , how about this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
axis1  order=(22,23,0,1,2,3,4,5) ;
proc gchart;
	vbar HOUR/ maxis=axis1 percent discrete;
  format HOUR z2.;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG title="aaa1.PNG" alt="aaa1.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/9452i6FD0228089F90B0C/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 02:40:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/367587#M87549</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-06-16T02:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Change the x-axis order in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/367588#M87550</link>
      <description>&lt;P&gt;1. This is one of the few cases where Radar Plots are useful, showing different levels over time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. The fastest solution, recode data and use formats to display what you want using a VBAR plot rather than a histogram plot. Though if you recode it probably won't matter which one you use. But since you're binning by the hour it likely doesn't matter anyways.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. If you are intersted in looking at your full 24 hour period, I recommend a radar chart. The 24 hour clock works well on that type of graph.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
 value time_fmt
 22 = 1
 23 = 2
 0 = 3
 1 = 4
 2 = 5
 3 = 6
 4 = 7
 5 = 8
 6 = 9
 ;
 
 value $ time2_fmt
 '1' = 22
 '2' = 23
 '3' = 0
'4' = 1
'5' = 2
'6' = 3
'7' = 4
'8' = 5
'9' = 6;
 run;
 
 proc sgplot data=have;
 where hour in (22, 23, 0:5);
 vbar hour2 / stat=freq;
 format hour2 $time2_fmt.;
 run;
 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 02:42:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/367588#M87550</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-16T02:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Change the x-axis order in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/369041#M88043</link>
      <description>&lt;P&gt;Thanks Chris,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Though I adapt other method, knowing how to put percentage on the bar and change the order are very helpful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 08:06:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/369041#M88043</guid>
      <dc:creator>Chung-Li</dc:creator>
      <dc:date>2017-06-21T08:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change the x-axis order in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/369043#M88044</link>
      <description>&lt;P&gt;Thanks Reeza,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I agree that this is the fastest solution!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 08:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-the-x-axis-order-in-SGPLOT/m-p/369043#M88044</guid>
      <dc:creator>Chung-Li</dc:creator>
      <dc:date>2017-06-21T08:08:24Z</dc:date>
    </item>
  </channel>
</rss>

