BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
statmam
Calcite | Level 5

Is it possible to create different titles for different plots within a single proc gplot, e.g. “Historical Admission Activity” for the first two, “SAT Scores by Year” for the next two, and “ACT Scores by Year” for the last two?  If so, how would I do that?  Running the code below gives all the graphs the ACT version of the title.

Because all the graphs for an institution must appear together (before the graphs for the next institution begin), using three separate
proc gplots does not solve the problem. Thanks in advance for any ideas you can suggest. 

proc gplot data=IPEDSData;                     

by inst_name;

options nobyline;

      title 'Historical Freshmen Admission Activity';

      plot  apps*year

            admits*year

            matrics*year/ overlay;

      plot  selectivity*year

            yield*year        / overlay;

      title 'SAT Scores by Year';

      plot  SAT_CR_75*year

            SAT_CR_25*year/ overlay;

      plot  SAT_Math_75*year

            SAT_Math_25*year/ overlay;

      title 'ACT Scores by Year';

      plot  ACT_Eng_75*year

            ACT_Eng_25*year/ overlay;

      plot  ACT_Math_75*year

            ACT_Math_25*year/ overlay;

run;

quit;

1 ACCEPTED SOLUTION

Accepted Solutions
Bill
Quartz | Level 8

statmam, you might just add some macro code, a where statement and the run statements. Something like the following should get you started ...

%macro one;

%do I = 1 %to 5; **number of institutions;

%if &1=1 %then %let inst="Institution1";

%else %if &I = 2 %then %let inst="Institution2";

and so on ...

proc gplot data=IPEDSData; 

      where inst_name="&inst";                   

*by inst_name;

*options nobyline;

      title 'Historical Freshmen Admission Activity';

      plot  apps*year

            admits*year

            matrics*year/ overlay;

      plot  selectivity*year

            yield*year        / overlay;

run;

      title 'SAT Scores by Year';

      plot  SAT_CR_75*year

            SAT_CR_25*year/ overlay;

      plot  SAT_Math_75*year

            SAT_Math_25*year/ overlay;

run;

      title 'ACT Scores by Year';

      plot  ACT_Eng_75*year

            ACT_Eng_25*year/ overlay;

      plot  ACT_Math_75*year

            ACT_Math_25*year/ overlay;

run;

%mend one;

%one;;

quit;

View solution in original post

10 REPLIES 10
BrunoMueller
SAS Super FREQ

Hi

As Proc GPLOT supports Run Groups, add a RUN; statement between the various graphs you create. This should give you what you want. See also sample below.

proc gplot data=sashelp.class;
  title 'first title';
 
plot  age * weight age * height / overlay;
run;
 
title 'second title';
 
plot  weight * age weight * height / overlay;
run;
quit;
statmam
Calcite | Level 5

Thanks, Bruno.  I gave your idea a try.  Unfortunately, the run groups caused the order to change, i.e. the first graph was produced for all institutions, and then the second graph for everyone, and so on - whereas I need to produce all the graphs for the first institution, and then all the graphs for the second institution, etc.  Thanks for the suggestion though.

Bill
Quartz | Level 8

statmam, you might just add some macro code, a where statement and the run statements. Something like the following should get you started ...

%macro one;

%do I = 1 %to 5; **number of institutions;

%if &1=1 %then %let inst="Institution1";

%else %if &I = 2 %then %let inst="Institution2";

and so on ...

proc gplot data=IPEDSData; 

      where inst_name="&inst";                   

*by inst_name;

*options nobyline;

      title 'Historical Freshmen Admission Activity';

      plot  apps*year

            admits*year

            matrics*year/ overlay;

      plot  selectivity*year

            yield*year        / overlay;

run;

      title 'SAT Scores by Year';

      plot  SAT_CR_75*year

            SAT_CR_25*year/ overlay;

      plot  SAT_Math_75*year

            SAT_Math_25*year/ overlay;

run;

      title 'ACT Scores by Year';

      plot  ACT_Eng_75*year

            ACT_Eng_25*year/ overlay;

      plot  ACT_Math_75*year

            ACT_Math_25*year/ overlay;

run;

%mend one;

%one;;

quit;

statmam
Calcite | Level 5

Thank you, Bill.  I am working on implementing your suggestion.  There are 3500+ institutions in the data set (although the program usually runs against a smaller subset of them), so an automatic numbering system will be required.  I'm hoping that perhaps the newfile=bygroup option will produce the numbered data sets for the looping step.

Bill
Quartz | Level 8

I gave you the manual view. You could create a list of the institutions and read it into the macro code and avoid all of the manual %let statements.

statmam
Calcite | Level 5

Ah, this is great.  Just what I needed.  Thanks to you both!

BrunoMueller
SAS Super FREQ

If your happy with the answers, please mark the discussion as answered, this will help others, when they search for similar questions

Bruno

statmam
Calcite | Level 5

Bruno, I have been trying to do so; however, for some reason those green and yellow buttons don't show for me (even though I am logged in).  One of the administrators is currently trouble-shooting the issue.  As soon as the buttons show up, I will come back to mark the question answered.  Thanks again for your kind assistance.   

BrunoMueller
SAS Super FREQ

Statmam

Thanks for the information.

Bruno

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 2779 views
  • 3 likes
  • 3 in conversation