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;
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;
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.
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.
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;
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.
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.
Have a look at this great blog by https://communities.sas.com/people/Chris%40SAS http://blogs.sas.com/content/sasdummy/2012/03/20/sas-program-by-processing/ it gives a great introduction on how to automate on the principle suggested by Bill
Ah, this is great. Just what I needed. Thanks to you both!
If your happy with the answers, please mark the discussion as answered, this will help others, when they search for similar questions
Bruno
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.
Statmam
Thanks for the information.
Bruno
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.