04-04-2013 08:41 PM
I've got a macro that iterates through the variables in a dataset and outputs a table with various responses and other summary statistics.
So, for example, one variable might be year and the table generated by proc tabulate would look like this:
Year Exposure Frequency Loss
2008 10423 0.1 5469
2009 45390 0.12 4987
2010 100542 0.2 29801
Many tables like this are generated for variables other than year and the results are formatted and outputted to a pdf.
My question is how can I accompany the tables with plots in the pdf. In the example above I would like to output the table and then above the table a plot of Year against frequency as a line chart, with year on the x-axis and frequency on the y-axis. I would like to do the same thing for every other variable that gets outputted from the proc tabulate procedure to the pdf.
Any ideas or pointers from anybody?
04-05-2013 08:55 AM
You have 2 choices for graphing: SAS/GRAPH (PROC GPLOT) or ODS GRAPHICS (PROC SGPLOT with a SERIES or a VLINE statement). If you are using EG, you can generate the GPLOT code easily from within the Graph Wizard. If you are in SAS 9.2/9.3, you can try the ODS GRAPHICS DESIGNER to build your graphs in point and click fashion. If you are using code for the TABULATE and you want to use code for the image, then you will need to decide which method you want to use.
If you are new to SAS and new to coding and you are at SAS 9.3, I'd recommend using PROC SGPLOT, as it is probably less verbose code-wise than GPLOT. There are LOTS of SGPLOT examples in user-group papers and on the web. Here are a few to get you started. The references section at the back of each paper lists a bunch of other papers.
Have fun with graphing!