Fmonkey2001
Fmonkey2001

Reputation: 147

Title on only first page

This is my first time using a programming related stack. So if this doesn't belong or should go somewhere please inform me and I will fix it.

I've just begun to use SAS Studio. I believe I have set up a title correctly, but I can't seem to get it only on the first page. It adds the title to every subsequent page I create. I've just begun watching tutorials on the SAS website, but I have yet to run across the answer to this particular question. Can anyone help point me in a correct direction?

Here is my code:

Data Question21;
Input Transfers Broken @@;
Datalines;
1 16 0 9 2 17 0 12 3 22 1 13 0 8 1 15 2 19 0 11
;

title color=red Bold underlin=3 "Assignment #1";

Proc Print;
run;

Proc sgplot;
scatter x=Transfers y=Broken;
run;

Proc reg;
model Broken=Transfers;
run;

and this is a sample of what happens when it runs:Output Data

Upvotes: 2

Views: 1515

Answers (1)

Joe
Joe

Reputation: 63424

TITLE is a global statement, and will take effect until you turn it off. So the simple answer is: after the PROC in which you want the title, and its RUN statement (or QUIT in those that use quit), enter

title;

Which will then clear all titles.

In a bit more detail:

Titles, and Footnotes, have a set of ten (each) that are in a sort of 'stack' (Setting one removes all higher ones). SAS stores them internally, and any time a PROC or anything else runs that supports a title, it will grab whatever is currently in the title and footnote stacks and show those titles and those footnotes.

It is important to remember that any PROC or DATA step doesn't submit fully until RUN or QUIT is reached, or else another PROC or DATA step is begun (called a "Step Boundary"). Since TITLE is a global statement, what'll happen is whatever is in the current title stack when the step boundary is reached will be shown. Notice what you actually see here...

title "One Title";
proc print data=sashelp.class;
title "Two Title";
run;
title "Three Title";
proc freq data=sashelp.class;
tables sex*age/list;
run;
title "Four";

A good habit is to always put TITLE statements in a consistent place - some disagree over where, but choose either:

  • Before the PROC/DATA statement
  • Immediately before RUN

and stick with it. Then, after every RUN, include a TITLE;, unless you intentionally have a common title.

For example, I might have an assignment that is to print SASHELP.CLASS, run some frequencies on it, and use PROC UNIVARIATE to look at the WEIGHT and HEIGHT variables.

title "SAS Class, Assignment One";
title2 "Written By Joe, 9/2/2015";  *these are global titles used for all printing;

title3 "Print of first 10 obs of SASHELP.CLASS";
proc print data=sashelp.class(obs=10);
run;
title3;

title3 "Freq of AGE, SEX in SASHELP.CLASS";
proc freq data=sashelp.class;
  tables age sex;
run;
title3;

title3 "Univariate Examination of SASHELP.CLASS";

title4 "HEIGHT variable";
proc univariate data=sashelp.class;
  var height;
run;
title4;

title4 "WEIGHT variable";
proc univariate data=sashelp.class;
  var weight;
run;
title3; *notice 3 here - ending all of 3;

title3 "Plot of SASHELP.CLASS Height v Weight";
proc sgplot data=sashelp.class;
  scatter x=weight y=height;
run;

title; *ends all titles!;

Upvotes: 3

Related Questions