Sample 51350: Create filled areas based on the value of the Y variable
The sample code on the
Full Code tab creates filled areas based on the value of the Y variable.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The sample code below creates filled areas based on the value of the Y variable.
data pe_data;
label pe10="Price-Earnings Ratio";
input year re pe re10 pe10 label;
%let thresholdPE=20;
uPE = ifn(pe10 gt &thresholdPE, pe10, &thresholdPE);
lPE = ifn(pe10 lt &thresholdPE, pe10, &thresholdPE);
datalines;
1881 8.748326716 12.63265306 7.537763587 18.21479737 .
1882 8.712312283 13.45454545 7.736350471 15.61534241 .
1883 8.772956612 13.51162791 7.860859788 15.21615679 .
1884 7.580501458 12.95 7.810135656 14.45259058 .
1885 6.838179787 13.67741935 7.82213087 13.27527484 .
1886 8.357775295 19.25925926 8.13992424 16.83662413 .
1887 8.703106708 16.90909091 8.352263165 17.36163361 .
1888 6.584913869 14.75 8.252704406 15.36958563 .
1889 7.977874028 20.15384615 8.280566537 16.08095171 .
1890 7.523849831 17.93333333 7.979979659 17.27778813 .
1891 9.393863217 16.68965517 8.044533309 15.73568663 .
1892 9.483735093 16.20588235 8.12167559 18.92413597 .
1893 7.682400812 15.16216216 8.01262001 17.70495851 .
1894 4.933176162 16.61538462 7.74788748 15.93062495 .
1895 7.59797756 26.5625 7.823867257 16.91267357 .
1896 6.570014733 17.08 7.645091201 16.58686842 .
1897 9.421492175 20.0952381 7.716929748 17.2693833 .
1898 10.48734391 15.74193548 8.107172752 19.21911004 .
1899 12.3032239 17.37142857 8.539707739 22.47147694 .
1900 12.60701841 12.70833333 9.048024598 18.30899549 .
1901 12.81585823 14.72916667 9.390224099 20.52280842 .
1902 14.72837353 16.24 9.914687943 22.16449102 .
1903 12.96021217 13.42857143 10.44246908 19.94828451 .
1904 11.71288058 12.60377358 11.12043952 15.6426204 .
1905 16.01557141 17.20408163 11.96219891 18.12062854 .
1906 17.38554578 14.73134328 13.04375201 19.72303606 .
1907 15.42972465 12.57894737 13.64457526 16.76602446 .
1908 13.12673905 10.37878788 13.90851477 11.73666722 .
1909 15.5465983 15.62068966 14.23285221 14.74267528 .
1910 16.01064582 13.26315789 14.57321495 14.48739753 .
1911 13.07481658 12.69863014 14.59911079 13.9511611 .
1912 14.45828571 15.45762712 14.572102 13.84369516 .
1913 12.752208 13.28571429 14.55130159 13.18194541 .
1914 10.42141782 13.28571429 14.42215531 11.64309536 .
1915 17.12750769 14.38461538 14.53334894 10.39429155 .
1916 26.46978462 10.60227273 15.44177282 12.49474629 .
1917 18.50660571 6.254901961 15.74946093 10.72194945 .
1918 12.14496 5.6328125 15.65128303 6.618908448 .
1919 9.753724352 7.929292929 15.07199563 6.152910614 .
1920 8.522778947 9.494623656 14.32320894 6.144371604 .
1921 3.473410651 8.8875 13.36306835 5.288353901 .
1922 8.313514286 25.17241379 12.74859121 6.542968118 .
1923 11.46633988 12.89855072 12.6200044 8.411304745 .
1924 10.88132254 9.010204082 12.66599487 8.186531413 .
1925 14.13519553 11.37634409 12.36676365 9.773386982 .
1926 14.34261943 10.12 11.15404713 11.56714746 .
1927 12.98738497 10.80645161 10.60212506 13.89565787 .
1928 16.33532632 15.79279279 11.02116169 19.3458461 .
1929 19.0578807 18.01449275 11.95157733 26.70068962 1929
1930 12.34864906 13.48447205 12.33416434 21.50222122 .
1931 8.634528671 16.4742268 12.85027614 16.49357344 .
1932 6.433376744 13.60655738 12.66226238 9.142699232 .
1933 6.7472 17.29268293 12.1903484 8.78597685 .
1934 7.292929412 23.95454545 11.83150908 13.25853075 .
1935 11.14754783 18.89795918 11.53274431 11.64868162 .
1936 14.64285957 18.10526316 11.56276833 17.50054293 .
1937 16.10775211 17.24509804 11.87480504 21.83884878 .
1938 9.253302857 10.00884956 11.1666027 13.57664964 .
1939 13.10607194 19.53125 10.57142182 16.18474091 .
1940 15.07353191 13.66666667 10.84391011 16.94344617 .
1941 14.95557707 10.04761905 11.47601495 13.96665086 .
1942 12.33659645 7.698275862 12.06633692 10.03241617 .
1943 10.93511724 9.796116505 12.48512864 10.01552807 .
1944 10.57566742 12.60638298 12.81340244 11.04131802 .
1945 10.67688791 14.50537634 12.76633645 11.97215468 .
1946 9.979579535 18.77083333 12.30000845 15.69863714 .
1947 13.75062278 14.3490566 12.06429551 11.64206937 .
1948 19.31386 9.211180124 13.07035123 10.49870365 .
1949 19.9831966 6.707423581 13.75806369 9.911458212 .
1950 22.63234016 7.275862069 14.51394452 10.56798292 .
1951 18.63754868 7.468309859 14.88214168 11.64571967 .
1952 18.26309774 9.913934426 15.47479181 12.4156482 .
1953 18.88714349 10.90833333 16.26999443 12.87383768 .
1954 20.99971236 10.14342629 17.31239893 11.77507151 .
1955 27.34126567 12.85198556 18.9788367 15.58928957 .
1956 25.00864348 12.1961326 20.4817431 17.5699758 .
1957 23.85111608 13.32258065 21.49179243 16.26715402 .
1958 20.17180138 12.20178042 21.57758656 13.54126614 .
1959 23.41946212 19.24567474 21.92121312 17.9918142 .
1960 22.21142013 17.1179941 21.87912111 18.28795752 .
1961 21.523568 18.26299694 22.16772305 18.54037445 .
1962 24.43640526 21.65203762 22.7850538 21.02286748 .
1963 26.33373204 17.72752044 23.52971265 19.01232613 .
1964 29.519 19.01741294 24.38164142 21.28370472 .
1965 33.03581887 18.92747253 24.95109674 22.9156049 .
1966 34.14616413 17.98073218 25.8648488 23.80689785 .
1967 31.63862991 15.21621622 26.64360018 20.08809023 .
1968 32.75045393 17.83114447 27.90146544 21.17405218 .
1969 30.95144127 17.71527778 28.65466336 20.79401134 .
1970 26.09030352 15.62456747 29.04255169 16.87693471 .
1971 28.07229197 18.22417154 29.69742409 16.37163882 .
1972 30.50494648 18.12280702 30.30427821 17.13107266 .
1973 35.44451845 18.44548287 31.21535685 18.5676248 .
1974 34.53892975 11.77818627 31.71734983 13.37393459 .
1975 28.97898129 8.161979753 31.31166607 8.888070624 .
1976 34.28961641 12.16834171 31.3260113 11.2618136 .
1977 35.26896384 10.4752775 31.68904469 11.46629374 .
1978 36.54157072 8.287419651 32.06815637 9.223651481 .
1979 38.66197635 8.086780211 32.83920988 9.21486248 .
1980 34.48051862 7.460969044 33.67823139 8.783883955 .
1981 32.97041103 8.972334683 34.16804329 9.186074813 .
1982 26.1609227 7.635416667 33.73364092 7.367785849 .
1983 27.86944534 11.41376582 32.97613361 8.851539214 .
1984 31.92608758 11.8595866 32.71484939 10.0230095 .
1985 26.9826438 10.31310096 32.51521564 10.06444996 .
1986 26.35776691 14.24982888 31.72203069 11.82517321 .
1987 30.61607606 18.26726519 31.25674191 15.17823127 .
1988 39.71432007 14.31314286 31.57401684 14.01976801 .
1989 36.336373 12.01220539 31.34145651 15.10915041 .
1990 32.09180862 14.86532575 31.10258551 17.23442627 .
1991 23.31961303 15.25304592 30.13750571 15.73817169 .
1992 27.09762581 26.15210559 30.23117602 20.23581475 .
1993 30.29317428 22.79884756 30.47354891 20.43568003 .
1994 41.21044311 21.61745887 31.40198447 21.48950392 .
1995 44.52103212 15.20424837 33.1558233 19.95331897 .
1996 49.27449202 18.09246172 35.44749581 24.29422615 .
1997 49.7522495 19.78363026 37.36111316 27.50062618 .
1998 46.44603287 24.25377644 38.03428444 32.29775118 .
1999 57.76290711 33.12387268 40.17693785 40.44962333 .
2000 57.80011422 29.59497613 42.74776841 42.54908284 2000
2001 28.21937346 26.6186 43.23774445 35.99154243 .
2002 30.73559406 46.18104496 43.60154128 30.14033621 .
2003 53.27081987 32.46973541 45.89930583 22.88856259 .
2004 62.14712533 22.17152236 47.99297406 25.73231016 .
2005 71.38149713 20.48181042 50.67902056 26.52233299 .
2006 81.51 18.04761905 53.90257135 25.42010586 .
2007 63.4335206 17.37725432 55.27069846 26.2774106 .
2008 14.2649772 22.3514657 52.0525929 25.65251027 .
2009 . 58.97580645 51.41811354 16.1622791 .
;
run;
ods graphics / reset width=600px height=400px;
title "The Danger of High Price-Earnings Ratios";
footnote j=l "Source: Robert J. Shiller";
proc sgplot data=pe_data noautolegend;
yaxis offsetmin=0;
refline 10 20 30 40 / lineattrs=GraphGridLines;
band x=year upper=lPE lower=0 / fillattrs=(color=vilg);
band x=year lower=&thresholdPE upper=uPE / fillattrs=(color=red);
refline &thresholdPE / label="PE=&thresholdPE";
series x=year y=pe10 / lineattrs=GraphData1(thickness=3 color=cx13478c) datalabel=label;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample creates filled areas based on the value of the Y variable.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGPLOT
|
Date Modified: | 2013-10-15 16:08:45 |
Date Created: | 2013-10-15 09:25:40 |
Operating System and Release Information
SAS System | SAS/GRAPH | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |
Microsoft® Windows® for x64 | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |
Microsoft Windows XP Professional | 9.2 TS1M0 | |
Windows Vista | 9.2 TS1M0 | |
Windows Vista for x64 | 9.2 TS1M0 | |
64-bit Enabled AIX | 9.2 TS1M0 | |
64-bit Enabled HP-UX | 9.2 TS1M0 | |
64-bit Enabled Solaris | 9.2 TS1M0 | |
HP-UX IPF | 9.2 TS1M0 | |
Linux | 9.2 TS1M0 | |
Linux for x64 | 9.2 TS1M0 | |
OpenVMS on HP Integrity | 9.2 TS1M0 | |
Solaris for x64 | 9.2 TS1M0 | |