Hi,
I was hoping someone could give me a start. I have a dataset from which I have created a sgpanel plot that is currently:
panelby Site Season Year
Instead what I want to do is to create a new sgpanel plot for each of the Sites so they will be panelby Season Year. I want it set up so that which sites and how many are in the data set won't matter ie the program will be able to work this out.
So I'm assuming that I need to have something that gets a unique list from the variable Site and then loops over the sgpanel code to produce a plot for each site in the list? Any suggestion on the easiest way to do this.
I'm using SAS Enterprise Guide Version 7.11 HF5
Thanks
Jo
Write the code for one Site.
Make it a macro using a WHERE clause and parameter for SITE.
Use a data step and CALL EXECUTE to execute it for every value. The CALL EXECUTE documentation has an example.
Write the code for one Site.
Make it a macro using a WHERE clause and parameter for SITE.
Use a data step and CALL EXECUTE to execute it for every value. The CALL EXECUTE documentation has an example.
The correct answer should be @Jay54 not my suggestion of a macro. BY processing is more efficient.
The "By Site" option did work (although in the code "by" stayed coloured red as if there was an issue) but probably is not that different a result than the "panelby Site Season Year". The only difference between these two is that in the results it puts a page break between the set of plots for each site. Why I was after each site done seperately is that the values are quite different and the sgpanel produces a single range on the y-axis that covered all values for all sites, which made a lot of the variation within site not easily visible.
For me the "Call execute" routine worked better as it produced a entirely new plot for each site and therefore the range on the y-axis is appropriate for each individual site.
Thanks heaps for the reponse thou, as I'm sure I'll have need to employ both options in further work and had not come across the by option before.
Thanks
Proc SGPANEL BY Site will also produce a new graph per site. You should use whichever method works for you best. You can also use more classifiers on the BY variable.
I suggest you only need to use:
proc sgpanel data=foo;
by Site;
panelby Season Year;
plot statements;
run;
I just noticed that the SGPROCEDURES don't have BY listed in their Syntax, rather it's in a generic section above which I didn't realize initially.
The STAT/PROCS do list a BY in the documentation. The inconsistency is confusing :S
Have you tried sorting your data by site and then using:
By Site;
Panelby Season Year ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.