![]() The REFLINE statement supports a SPLITCHAR= option that you can use to split a long label across multiple lines.In the example, DISCRETEOFFSET=0.5 moves the line between the reference category and its neighbor to the right. Positive values move the line to the right negative values move the line to the left. You can use the DISCRETEOFFSET= option and a value in the interval to move the line left or right of center. By default, the reference line will be in the middle of the category.If the categorical variable has a format, you need to specify the formatted value.In the following example, I use a reference line to indicate a fiscal year. Another application is simply drawing a line that separates one set of categories from another. ![]() One application that I can think of is displaying an expected value for a discrete probability distribution. You can also display reference lines on a discrete axis, although it is not common. Refline 120 130 / axis=y label= ( 'Elevated' 'Hypertensive' ) lineattrs=GraphData2 Refline 200 240 / axis= x label= ( 'Borderline' 'High' ) lineattrs=GraphData2 Heatmap x=Cholesterol y=Systolic / colormodel= (CXDEEBF7 CX9ECAE1 CX3182BD ) Title "Clinical Ranges of Systolic Blood Pressure and Cholesterol" The following example adds labels to the previous example. LABELPOS= option to specify whether the label is displayed at the top or bottom (for a vertical reference line) orĪt the left or right (for a horizontal reference line). I like "outside" (the default) because then the line does not interfere with the label. LABELLOC= option to put the label inside or outside the data area of the graph. You can use the LABEL= option to specify one or more labels. If you might want to add a label to the reference lines, In this example, I used the optional LINEATTRS= option to show how to change the color, line pattern, and thickness of the reference lines. Put REFLINE stmt first if you want it behind the bars */ run Refline 200 240 / axis= x lineattrs= (thickness= 3 color=darkred pattern=dash ) Set sashelp.Heart ( where= (Cholesterol< 400 ) ) You can use reference lines to indicate good, borderline, and high cholesterol. The following histogram shows the distribution of cholesterol values for 5,195 subjects. The Sashelp.Heart data set contains cholesterol and blood pressure information for patients in a heart study. A cholesterol level that is 240 or more is considered high. A "borderline" (or moderately elevated) cholesterol level is between 200 and 240 mg/dL. The reference lines are perpendicular to the axis.Ī simple use of a reference line is to indicate a reference value on a histogram.įor example, a healthy total cholesterol level is less than 200 mg/dL. You then use the AXIS=X or AXIS=Y option to specify which axis the reference lines are for. You can specify one or more values (separated by spaces) or you can specify a variable in the data set that contains the values at which to display the reference lines. The REFLINE statement in PROC SGPLOT is easy to use. ![]() Use reference lines for a categorical variable on a discrete axis.Display a reference line at a value such as a mean or median.This article provides multiple "Getting Started" examples that show how to use the REFLINE statement This article discusses the REFLINE statement in PROC SGPLOT in SAS. Sometimes you can let the data "speak for themselves" in an unadorned graphic, but sometimes it is helpful to add reference lines to a graph to emphasize key features of the data. A purpose of data visualization is to convey that story to the reader in a clear and impactful way. quietly regress alcuse i.id#c.Data tell a story. Predicted values from this regression can then be plotted. In the nextĮxample, we regress alcuse on age interacted with id. We can also plot fitted lines using the xtline command. xtline alcuse if id < 10, overlay t(age) i(id) legend(off) scheme(s2mono) To do this, we add overlay to our command. Suppose we are interested in seeing all of the above lines in one plot. This example generates plots for the first 9 children’s observations in the file xtline alcuse if id < 10, t(age) i(id) scheme(s2mono) A separate plot will be created for eachĭifferent id value. The time variable we specify willĪppear on the horizontal axis. The outcome that we wish to examine,Īlcohol use, will appear on the vertical axis. We indicate that our time variable is age with t(age) and our This first example shows a line connecting the three time points broken downīy id (one plot per child). ![]() Produces plots in grayscale, because publications often require monochromatic plots.įirst, we read in the data file. Of alcohol use, alcuse, taken at ages 14, 15 and 16 for 82 children We will show a number of examples from a data file which contains a measurement The xtline command allows you to generate linear plots for panel data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |