You can use the title statement in SAS to quickly add a title to a table or chart.
This statement uses the following basic syntax:
Method 1: Add One Title
/*define title*/
title "This is a title";
/*view dataset with title*/
proc print data=my_data;
Method 2: Add Multiple Titles
/*define titles*/
title1 color="purple" height=25pt bold italic underline=1 "This is a Title";
title2 font="Helvetica" justify=left height=18pt "Second Title";
title3 color="green" justify=right height=14pt "Third Title";
/*view dataset with title*/
proc print data=my_data;
Note the following statements that you can use to modify the titles:
- color: The font color
- height: The font size
- font: The font family
- justify: The location of the title (left, right, center)
- style: Use “bold”, “italic”, or “underlin” to modify the font style
The following examples show how to use each method in practice.
Example 1: Add One Title
The following code shows how to add one title to a dataset in SAS:
/*create dataset*/
data original_data;
input team $ points rebounds;
datalines;
A 25 10
A 18 4
B 27 9
B 33 13
;
run;
/*view dataset*/
title "This is a title";
proc print data=original_data;
Example 2: Add Multiple Titles
The following code shows how to add multiple titles with custom designs to a dataset in SAS:
/*create dataset*/
data original_data;
input team $ points rebounds;
datalines;
A 25 10
A 18 4
B 27 9
B 33 13
;
run;
/*view dataset*/
title1 color="purple" height=25pt bold italic underlin=1 "First Title";
title2 font="Helvetica" justify=left height=18pt "Second Title";
title3 color="green" justify=right height=14pt "Third Title";
proc print data=original_data;
Note that you can use the title1, title2, title3, etc. syntax to add up to 10 lines of titles to a chart or table.
Additional Resources
The following tutorials explain how to perform other common tasks in SAS:
How to Use Proc Summary in SAS
How to Use Proc Tabulate in SAS
How to Create Frequency Tables in SAS