What Are The Available Options To Use In VBAR? SG Procedure. » My Blogging

What are the available options to use in VBAR? SG Procedure.

If I want to find out what’s available in the VBAR, I could click this link and see all of the different options available. In addition to the VBAR, looked at other statements such as x-axis, y-axis, and key legend. Another nice thing about the documentation is broken up by syntax, overview, concepts, and examples. So much good information at your fingertips. Make sure you check out this documentation.

Next, let’s look at the PROC SGPAEL, and the PROC SGSCATTER steps. These procedures are similar in the fact that they create multi-cell graphs. SGPANEL is based on classification variables. If you know SGPLOT, this procedure is simple because it uses much of the same syntax. The biggest difference is the addition of the PANEL BY statement. Let’s start off by comparing SGPLOT to SGPANEL. In this PROC SGPLOT step, I have one plot statement, a VBAR statement. Compare that to this PROC SGPANEL step. We got the exact same VBAR statement.

The syntax that’s different is that we have a PANELBY statement. Instead of creating one cell with one bar chart, we want a cell per type of car. The layout that is used automatically with the PANELBY statement is the layout by the panel. I’m going to run both of these steps. The first graph that we see is from SGPLOT. It is a single cell where we are seeing the average manufacturer’s suggested retail price for each region. Compare that to the second graph. In the second graph, we had a PANELBY statement for type. Each type is a different cell. So now, we get multiple bar charts. That is what SGPANEL is. It’s creating multiple cells where a different percentage of the population is represented in each one of the cells. Let me show you a couple other examples with PROC SGPANEL.

On the PANELBY statement, earlier we specified one variable type, and it was using the default layout of the panel. On this PANELBY statement, we are specifying type and origin with a layout of the lattice. In each cell, we are wanting to see on the x-axis horsepower, and on the y-axis in MSRP. Here is the result. Multiple cells. The columns represent the different types. We have a type of SUV, a type of Sedan, and a type of sports. Whereas the rows represent different origins. So the first row is for the origin of Asia, the second row is for the origin of Europe, and the third is for the USA. With SGPANEL, you can quickly easily compare plots per different PANELBY variables. Just to show you, you can go pretty simple with your syntax, or we can add to that syntax. For example, the syntax that we already know about the regression statement that we can use with SGPLOT, we can use that with SGPANEL.

In addition, there are other statements that we might want to add. Instead of the x-axis and the y-axis statement, SGPANEL actually uses the row axis and the call axis statements. In this example, we have specified the row axis to show the values 0 to 125,000, incrementing by 25,000. Here is the result of that last PROC SGPANEL step. We can notice the difference for the row axis. It’s 0 to 125,000. In addition, our regression looks different because we’ve added options such as CLM, CLI, and marker adders. What I want you to realize about PROC SGPANEL, each cell has the same axis represented. The x-axis represents horsepower, the y-axis represents MSRP. So that’s what PROC SGPANEL is all about. Within one cell, you will get that x and y-axis, but you will see the same x and y-axis in every cell.

Moving onto the SGSCATTER Procedure, which also creates multi-cell graphs. Whereas SGPANEL created multiple cells with each cell containing the same x-axis and the same y-axis across all cells, SGSCATTER can use a different axis for each cell. SGSCATTER is limited to creating scatter-type plots, and there are only three plot statements available with this procedure. Here, you see three steps. With the PROC SGSCATTER, the first one has a plot statement, the second has a compare statement, and the third has a matrix statement. Let’s look at the plot statement first. For this plot statement, we want two cells.

In the first cell, we want the y-axis to be MPG Highway, and the x-axis to be horsepower. In the second cell, we want MSRP as the y-axis and invoice as the x-axis. Here is the result. What I want you to see is for these cells, we have a completely different axis being represented. The first cell is NPG and horsepower. The second cell is MSRP and invoice. That was not the case with SGPANEL. In the second example, with the compare statement, in this case, what we are saying is that the y-axis of MSRP is going to be shared with two cells. In the first cell, our x-axis will be NPG Highway. Our second cell, the x-axis will be horsepower. Again, MSRP on the y-axis is shared for both of those cells. Here is the result. Two different axes for our two different cells, but this y-axis of MSRP applies to Cell one, but it also applies to Cell two.

The last example PROC SGSCATTER is using the matrix statement. With the matrix statement, you just specify variables. In this case, the matrix statement has three variables specified. NPG Highway, horsepower, and MSRP. Those three variables will make up three columns and three rows. In addition, we have specified, in the diagonal, we want there to be a histogram and a normal density curve. Look at the result. The first column is NPG, the second column is horsepower, the third column is MSRP. As far as the rows, those three columns are used. You’ll notice in the diagonals, we see the histogram. The first histogram is for NPG, the second is for horsepower, and the third is for MSRP. Within a given cell, we can see what the axis represents.

This second cell here represents horsepower on the x-axis, and NPG highway on the y-axis. This matrix statement is a quick, easy way to refer to numeric variables and see the relationship within a graph scatterplot. To conclude this demo, remember, SGPANEL and SGSCATTER are similar in the case that they both create multi-cell plots. Next, I have a couple more SG Procedures that I want to show you. SGPIE, and SGMAP. SGPIE came about and SAS 9.4 maintenance 6 as pre-production, meaning SAS is still developing the procedure, but feel free to experiment with it. SGMAP came about as production in SAS 9.4 maintenance five.

Looking at an example of PROC SGPIE, in this example, we are referring to sashelp.baseball. We have a pie statement. We want to see a pie slice per each league value. In this case, without specifying statistics, the pie slice will represent the number of observations with that value of the league. What we can see as a result, the American League has 175 players, where the National League has 147 players. Instead of getting a pie chart on frequency, you may want to specify a response variable. In this example, we have specified on our pie statement after the forward-slash response equals in runs. We want to see the sum of the number of runs per each league. In addition, we’ve added a format statement so that the number of runs will be displayed with commas.

In this result, we see that the National League has 7,053 runs, compared to the American League that has 9,761. Not only can PROC SGPIE create pie charts, but it can also create a donut chart. A donut chart is a pie chart with a hole in the middle. We will get a donut for the league, looking at the sum of the number of runs, and we have specified the whole label option, where we will specify the text of a number of runs within the donut. The result of the donut chart is just a variation of the pie chart. Let’s finish up this demo by looking at PROC SGMAP using the data set of SAS Help period quakes. In these examples of PROC SGMAP, I’m using the option Plot Data and referring to my SAS Help Data Set.

I’m also subsetting the data so that I’m only going to get the earthquakes from the United States that have a magnitude greater than 5. Within the PROC SGMAP step, I need to specify the map that I want to use. I’m showing you two examples. You can use an open street map, and it’s as simple as just saying Open Street Map semicolon, or you can use Esri maps. If you use Esri maps, you will need to specify URL equals and specify the Esri map that you want to use. If I scroll to the right. Here’s the URL for me to be able to use the Esri map called World Dark Gray Base.

In both of these procedures, we are specifying the same bubble statement. We want to plot the x of the longitude value, the latitude value, and the size of the magnitude value. In order for you to use PROC SGMAP, you need to have a data set that has coordinates in it. Well, if you go check out sashelp.quakes, you will see that there is longitude and a latitude variable in the data set. So for each earthquake, it will go to that latitude and longitude value and display a marker symbol. But it’s not just a marker symbol, because instead of the scatter statement, we are using the bubble statement. With the bubble statement, we are saying where it’s marking the earthquake. We want the size of that earthquake to be represented based on the magnitude variable. So the higher the magnitude, the bigger the bubble. Let’s compare the result of the two PROC SGMAPS. In the first graph that I see, this is an example of the Open Street Map.

Related Posts

4 thoughts on “What are the available options to use in VBAR? SG Procedure.

  1. Hmm is anyone else encountering problems with the images
    on this blog loading? I’m trying to figure out if its a problem on my end or if
    it’s the blog. Any suggestions would be greatly appreciated.

Leave a Reply

Your email address will not be published.