What are the basic steps of PROC? SG Procedure.

We’re using the weight and the cholesterol. Then, we are switching data sets, and we’re going to SAS Help period stocks. In the first PROC step, we have a where statement, where we are sub-setting for stock equals IBM, and the year of the date equals 2005. In that PROC SGPLOT, we are looking at a step statement. X is equal to the variable date, and y is equal to the close price of that stock. Versus in the last step that’s highlighted, instead of using a step statement on as help.stocks, we are using a high-low. For each date that we have in the data set, we want to draw a line from the highest price of the stock to the lowest price of the stock.


I got three graphs to show you. This first one is the one that is coming from the heat map. We have a heat map for weight and cholesterol. The more observations that we have for a given weight and cholesterol, the different colors we will see. For example, the higher the frequency is represented with the red color. Here is an example of a step plot. And in this case, we are connecting the closing prices. Not a direct connecting the dots, but instead, a stairstep.

In the graph, we’re using that stock data, but again, for a given date, we are showing the stock price, the low value to the high value. At this point, I’ve shown you numerous plot statements that you can use with PROC SGPLOT. These are just some of them. It is by no means all of the different plot types. What I wanted to show you is how simple it is to get a graph created. Just add that one plot statement between the PROC and the run. I kept my plot statements fairly simple. I didn’t add a lot of options. But just like I showed you in the last demo, there’s a lot that you can add to a PROC step.

The same applies to these plot types. Look at this PROC SGPLOT. I took that last example that we were using with a high-low, and I’ve added a lot more syntax. If you look at the plot statement itself, I have my x, my high, my low, but then I’ve specified options. I want to label my low and high ends. I want the low and the high ends to be serif, or like a T. I want to have tick marks that show the open value and the closed value. Furthermore, I specify a color response, so the color of my lines is going to represent the quantity of value. The color model that I’m using is a color scale between three different RGB colors. In addition, I’ve specified label attributes and line attributes. In addition, we’ve specified axis statements with the x-axis and the y-axis statements.

On those statements, we specified things such as value adders, what we want to display, our label, our label adders, whether we want there to be minor tick marks and gridlines, and what those grid attributes should look like. The last statement we added inside this PROC step is the gradient legend. The gradient legend goes back to the color response of volume and the color of the model. That gradient legend is going to be positioned at the bottom with no border and tidal attributes. Let’s compare the difference. Here is the example of the PROC SGPLOT with nothing more than a very simple high-low. If I scroll down, that last example that I showed you with all of the additional statements and options, produced this result.

I’m still getting my high-low, but I got a label at the low end in the high end. It is serif endpoints, so you see that T. Within the line, you see marks, which represent the opening and the closing values. In addition, the color of each line is being represented by the volume value. The higher the volume, the darker the color. So the one with the highest volume was in April. That color response created the gradient legend that we see positioned at the bottom. Just to go back to that code one more time, that’s a lot of syntaxes. That’s a lot of options and statements. My suggestion to you is that you give this a try. You type this up one statement at a time, one option, to see the difference of what each item will do for you.

Your head might be spinning. That has been a lot of syntaxes for us to look at. What I want you to realize, is if I’m coding with SG Procedures, I’m constantly looking at the documentation. I’m not expecting you to remember everything that you hear in this presentation, not expecting you to memorize it all. Documentation is at your fingertips. Use it. I could not live without my ODS Graphics documentation. What you need to do, is go to a search engine like Google. Put in ODS Graphics Suite. That is going to take you to the documentation. From there, there are numerous pieces of documentation. What we are going to focus on, is the ODS Graphics Procedures Guide.

In that guide, you will find the documentation of all five of the procedures that we are looking at in this presentation. At this point, I’ve already gone to a web browser and searched ODS Graphics Suite. Here is the web page that is taking me to, and this is the documentation page for the ODS Graphics Suite. Later in this presentation, I will supply you with the link. If I scroll through this web page, I see documentation, and this is the SAS ODS Graphics Suite in SAS Viya. I see an overview section, SAS ODS Graphics Procedures, a mapping section, graph template language, related documentation, and example and resources. If you want to look at the documentation for something other than SAS Viya, you can go down below where it says Previous Versions, and you can pick your version of SAS 9. Let me scroll back up. I have been showing you SG Procedures.
It’s right here in the SAS ODS Graphics Procedures Guide, that I can get to the documentation of SGPLOT, but I can also get to the documentation of SGPANEL, SGSCATTER, and SGPIE. If I’m interested in getting to the documentation of SGMAP, I need to go a little further down to the SAS graph and Base SAS Mapping Reference.

For now, since we just talked about PROC SGPLOT, let me click on the ODS Graphics Procedures Guide. Here is the documentation. If I scroll down, I can see the section of the procedures, and I see what SG procedures are included in this guide. Notice, you will see SGPLOT Procedure. If I click on this link, I will see all of the different syntaxes that I can include in this procedure. If I scroll through the SGPLOT Procedure Page, numerous plot statements can be included. In addition, some of these are plot statements, but additional statements are appearance statements. For example, we looked at the VBAR statement.

Leave a Comment