<?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: How to restrict result values in Bar chart. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819456#M323465</link>
    <description>&lt;P&gt;Not commenting on whether this is a good idea or bad idea but it's possible. DATALABEL allows you specify a variable for the label so specify the original variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test1;
vbar n/response=result_ datalabel = result;
xaxis label='N=xx' display=(novalues noticks);
yaxis label='Results';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/143413"&gt;@Sairampulipati&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you Miler, here is the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input result 8.;&lt;BR /&gt;datalines;&lt;BR /&gt;424&lt;BR /&gt;56&lt;BR /&gt;33&lt;BR /&gt;26&lt;BR /&gt;20&lt;BR /&gt;14&lt;BR /&gt;13&lt;BR /&gt;4&lt;BR /&gt;2&lt;BR /&gt;1&lt;BR /&gt;-7&lt;BR /&gt;-10&lt;BR /&gt;-13&lt;BR /&gt;-15&lt;BR /&gt;-20&lt;BR /&gt;-24&lt;BR /&gt;-35&lt;BR /&gt;-37&lt;BR /&gt;-38&lt;BR /&gt;-54&lt;BR /&gt;-69&lt;BR /&gt;-72&lt;BR /&gt;-84&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;set test;&lt;BR /&gt;n=_n_;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sgplot data=test;&lt;BR /&gt;vbar n/response=result datalabel;&lt;BR /&gt;xaxis label='N=xx' display=(novalues noticks);&lt;BR /&gt;yaxis label='Results';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data test1;&lt;BR /&gt;set test;&lt;BR /&gt;if result &amp;gt; 100 then result_=120;&lt;BR /&gt;else result_=result;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sgplot data=test1;&lt;BR /&gt;vbar n/response=result_ datalabel;&lt;BR /&gt;xaxis label='N=xx' display=(novalues noticks);&lt;BR /&gt;yaxis label='Results';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;I am new to plots so I am not sure how to apply formats to data to show 120 as 424 in plot.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jun 2022 20:12:46 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-06-21T20:12:46Z</dc:date>
    <item>
      <title>How to restrict result values in Bar chart.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819447#M323460</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have result values as 424, 56, 33, 26, 20, 14, 13, 4, 2, 1, -7, -10, -13, -15, -20, -24, -35, -37, -38, -54, -69, -72, -84. I am plotting a bar chart using the following code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=test;&lt;/P&gt;&lt;P&gt;vbar n/response=result datalabel;&lt;/P&gt;&lt;P&gt;xaxis label = 'N=xx' display=(novalues noticks);&lt;/P&gt;&lt;P&gt;yaxis label= 'Results' ;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sairampulipati_0-1655839671382.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72512iE951BE0632C63BD1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sairampulipati_0-1655839671382.png" alt="Sairampulipati_0-1655839671382.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;After running the above code am getting result like this, but the I need to restrict y-axis values as -100 to 140 by 20 and 100&amp;amp;above to display within 140. For that I harcoded the value above 100 to&amp;nbsp; 120 like (if result &amp;gt; 100 then result_ = 120; else result_ = result;) with that update I have run the same code changing ressponse = result_ (new variable created0 but the data label show the new hardcoded value as 120 for the observations above 100. But I wanted to show the actual result value 424 in the place of 120, is that possible.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sairampulipati_1-1655840172920.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72513iFDD5105E698739A4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sairampulipati_1-1655840172920.png" alt="Sairampulipati_1-1655840172920.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 19:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819447#M323460</guid>
      <dc:creator>Sairampulipati</dc:creator>
      <dc:date>2022-06-21T19:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict result values in Bar chart.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819449#M323461</link>
      <description>&lt;P&gt;Its really hard to know what you did when you show us small parts of your program, and write words to describe the rest of the program. Show us the relevant parts of your program, PROCs and DATA steps need to be complete. Do not show us partial PROCs or partial DATA steps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, have you tried formatting the data so 120 is shown as 424?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 19:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819449#M323461</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-21T19:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict result values in Bar chart.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819452#M323463</link>
      <description>&lt;P&gt;Thank you Miler, here is the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input result 8.;&lt;BR /&gt;datalines;&lt;BR /&gt;424&lt;BR /&gt;56&lt;BR /&gt;33&lt;BR /&gt;26&lt;BR /&gt;20&lt;BR /&gt;14&lt;BR /&gt;13&lt;BR /&gt;4&lt;BR /&gt;2&lt;BR /&gt;1&lt;BR /&gt;-7&lt;BR /&gt;-10&lt;BR /&gt;-13&lt;BR /&gt;-15&lt;BR /&gt;-20&lt;BR /&gt;-24&lt;BR /&gt;-35&lt;BR /&gt;-37&lt;BR /&gt;-38&lt;BR /&gt;-54&lt;BR /&gt;-69&lt;BR /&gt;-72&lt;BR /&gt;-84&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;set test;&lt;BR /&gt;n=_n_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sgplot data=test;&lt;BR /&gt;vbar n/response=result datalabel;&lt;BR /&gt;xaxis label='N=xx' display=(novalues noticks);&lt;BR /&gt;yaxis label='Results';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data test1;&lt;BR /&gt;set test;&lt;BR /&gt;if result &amp;gt; 100 then result_=120;&lt;BR /&gt;else result_=result;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sgplot data=test1;&lt;BR /&gt;vbar n/response=result_ datalabel;&lt;BR /&gt;xaxis label='N=xx' display=(novalues noticks);&lt;BR /&gt;yaxis label='Results';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;I am new to plots so I am not sure how to apply formats to data to show 120 as 424 in plot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 19:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819452#M323463</guid>
      <dc:creator>Sairampulipati</dc:creator>
      <dc:date>2022-06-21T19:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict result values in Bar chart.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819454#M323464</link>
      <description>&lt;P&gt;Are you actually intending to mislead the reader of your graph and imply that the value is actually 120 when in reality it was 424? Or do you want something so that the height of the bar is not drastically longer than others?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider (note, I am nice enough to provide a data set to actually graph):&lt;/P&gt;
&lt;PRE&gt;data example;
   do y=424, 56, 33, 26, 20, 14, 13, 4, 2, 1, -7, -10, -13, -15, -20, -24, -35, -37, -38, -54, -69, -72, -84;
      x +1;
      output;
   end;
run; 

/* as is*/
proc sgplot data=example;
   vbar x/response=y datalabel;
   xaxis label = 'N=xx' display=(novalues noticks);
   yaxis label= 'Results' ;
run;

/* break in yaxis*/
proc sgplot data=example;
   vbar x/response=y datalabel;
   xaxis label = 'N=xx' display=(novalues noticks);
   yaxis label= 'Results' ranges=(-100-100 400-450) ;
run;
&lt;/PRE&gt;
&lt;P&gt;The second graph makes much more sense than trying to corrupt an actual value.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 20:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819454#M323464</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-21T20:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict result values in Bar chart.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819456#M323465</link>
      <description>&lt;P&gt;Not commenting on whether this is a good idea or bad idea but it's possible. DATALABEL allows you specify a variable for the label so specify the original variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test1;
vbar n/response=result_ datalabel = result;
xaxis label='N=xx' display=(novalues noticks);
yaxis label='Results';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/143413"&gt;@Sairampulipati&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you Miler, here is the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input result 8.;&lt;BR /&gt;datalines;&lt;BR /&gt;424&lt;BR /&gt;56&lt;BR /&gt;33&lt;BR /&gt;26&lt;BR /&gt;20&lt;BR /&gt;14&lt;BR /&gt;13&lt;BR /&gt;4&lt;BR /&gt;2&lt;BR /&gt;1&lt;BR /&gt;-7&lt;BR /&gt;-10&lt;BR /&gt;-13&lt;BR /&gt;-15&lt;BR /&gt;-20&lt;BR /&gt;-24&lt;BR /&gt;-35&lt;BR /&gt;-37&lt;BR /&gt;-38&lt;BR /&gt;-54&lt;BR /&gt;-69&lt;BR /&gt;-72&lt;BR /&gt;-84&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;set test;&lt;BR /&gt;n=_n_;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sgplot data=test;&lt;BR /&gt;vbar n/response=result datalabel;&lt;BR /&gt;xaxis label='N=xx' display=(novalues noticks);&lt;BR /&gt;yaxis label='Results';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data test1;&lt;BR /&gt;set test;&lt;BR /&gt;if result &amp;gt; 100 then result_=120;&lt;BR /&gt;else result_=result;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sgplot data=test1;&lt;BR /&gt;vbar n/response=result_ datalabel;&lt;BR /&gt;xaxis label='N=xx' display=(novalues noticks);&lt;BR /&gt;yaxis label='Results';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;I am new to plots so I am not sure how to apply formats to data to show 120 as 424 in plot.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 20:12:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819456#M323465</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-21T20:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to restrict result values in Bar chart.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819555#M323510</link>
      <description>&lt;P&gt;Thank you very much Reeza for the help, certainly it worked well. The read wants in such a way that above hundred should be like 100+ in the y-axis and actual result values in the data label. I have changed the code to&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=test1;&lt;/P&gt;&lt;P&gt;vbar n/response=result_ datalabel=result;&lt;/P&gt;&lt;P&gt;xaxis label='N=xx' display=(novalues noticks);&lt;/P&gt;&lt;P&gt;yaxis label='Results' values=(-100 -80 -60 -40 -20 0 20 40 60 80 100 120) valuesdisplay=('-100' '-80' '-60' '-40' '-20' '0' '20' '40' '60' '80' '100' '100+');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;And now the output looks as per the reader requirement&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sairampulipati_0-1655891235060.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72536i1F4C5422AA98222E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sairampulipati_0-1655891235060.png" alt="Sairampulipati_0-1655891235060.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 09:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-restrict-result-values-in-Bar-chart/m-p/819555#M323510</guid>
      <dc:creator>Sairampulipati</dc:creator>
      <dc:date>2022-06-22T09:47:42Z</dc:date>
    </item>
  </channel>
</rss>

