{"id":414,"date":"2020-04-10T17:15:20","date_gmt":"2020-04-10T21:15:20","guid":{"rendered":"http:\/\/pressbooks.library.upei.ca\/montelpare\/?post_type=chapter&#038;p=414"},"modified":"2020-10-31T08:56:17","modified_gmt":"2020-10-31T12:56:17","slug":"graphing-data-for-effective-presentations","status":"publish","type":"chapter","link":"https:\/\/pressbooks.library.upei.ca\/montelpare\/chapter\/graphing-data-for-effective-presentations\/","title":{"raw":"Graphing Data for Effective Presentations","rendered":"Graphing Data for Effective Presentations"},"content":{"raw":"<div class=\"textbox textbox--learning-objectives\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">Learner Outcomes<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\nAfter reading this chapter you should be able to:\r\n<ul>\r\n \t<li>Organize data from various sources, and especially identify the specific variables that comprise a data set and separate data into independent and dependent measures.<\/li>\r\n \t<li>Present your data in a graphical format to convey your message to the reader by identifying the level of measurement for each of the variables within the data set and organize the data appropriately for the type of graph or table selected<\/li>\r\n \t<li>Select from a variety of graphing and charting features in SAS to create an appropriate visual presentation of variables in your dataset and thereby demonstrate when a graph of a particular type is most appropriate<\/li>\r\n \t<li>Prepare your data set for graphing and charting by transposing from wide to narrow or narrow to wide<\/li>\r\n \t<li>Create a simple SAS program to produce different types of graphs and tables<\/li>\r\n \t<li>Add specific features such as axis labels, legends, and colors to enhance your graphical presentation of variables in the data set<\/li>\r\n<\/ul>\r\n<\/div>\r\n<\/div>\r\n<h2>Preamble<\/h2>\r\nProducing graphical images is one of the most important features of conveying the statistical message. Face it, statistics is a hard area to wrap your brain around because it is based on the complexity of mathematically derived outcomes. What is the chance of picking the correct lottery number? How many people do I need in my study to know that I can represent the population? What is the best outcome from the randomized clinical trial that I should achieve before I decide that the vaccine is effective? Chance, probability, estimation, hypotheses, confidence, prediction, these are all complex concepts in which we only estimate the likelihood of our accuracy.\r\n\r\nStatistics is the science that helps us to create knowledge based on the information attributed to the facts that make up our datasets.\r\n\r\nGraphing is an approach that enables us to bring the data from the abstractness of a fact to the reality of a contextualized image. With a graph, we view the image and then interpret the meaning of the image from our understanding of the mathematical system that the image represents.\r\n\r\nIn applying statistics, and more specifically learning statistics, graphs are essential.\r\n<h2>Creating a Visual Presentation of Your Data<\/h2>\r\nIn this section, we will organize data from various sources, and especially identify the specific variables that comprise a data set and separate data into independent and dependent measures. The examples here will enable us to present data in a graphical format to convey our message to the reader by identifying the level of measurement for each of the variables within the data set and organize the data appropriately for the type of graph or table selected.\r\n\r\nGraphing is a useful technique to illustrate:\r\n<ul>\r\n \t<li>the shape of data sets relative to how scores are distributed<\/li>\r\n \t<li>relationships or associations between variables within or between data sets<\/li>\r\n \t<li>the magnitude of differences for numbers within and between datasets<\/li>\r\n<\/ul>\r\nIn this section, we will use several different examples of graphing and charting features in SAS to create the appropriate visual presentation of variables in our dataset and thereby demonstrate when a graph of a particular type is most appropriate. In addition, we will work through examples that prepare data sets for graphing and charting by transposing from wide to narrow or narrow to wide, as well as adding specific features such as axis labels, legends, and colors to enhance your graphical presentation of variables in the data set.\r\n<h2>Creating a Vertical Bar Chart to Represent John Snow's Natural Experiment<\/h2>\r\n<span class=\"tablepress-table-description tablepress-table-description-id-5\">In this first example, we will use the PROC SGPLOT command to create a vertical bar graph to represent the data that John Snow reported for the water source by household in his 1854 surveillance during the London Cholera epidemic. The data are discrete frequencies of households which are then plotted against the source of drinking water for the household. The SAS code used to generate this vertical bar chart is presented below the image.\u00a0<\/span>\r\n\r\nIn this SAS graphing program we create a vertical bar graph to represent the data that John Snow reported for the water source by household in his 1854 surveillance during the London Cholera epidemic. The data are discrete frequencies of households and these are plotted against the source of drinking water for the household.\r\n\r\nThe SAS Code to generate the Vertical Bar Chart above.\r\noptions pagesize=55 linesize=120 center date;\r\nPROC FORMAT;\r\nVALUE SLICE 1 = 'Southwark &amp;amp; Vauxhall'\r\n2 = 'Lambeth'\r\n3 = 'Thames River'\r\n4 = 'Pumps and Wells'\r\n5 = 'Ditches'\r\n6 = 'Unknown';\r\ndata snow1;\r\ninput source deaths ;\r\nlabel Source = 'Water Source';\r\ndatalines;\r\n1 286\r\n2 14\r\n3 22\r\n4 04\r\n5 04\r\n6 04\r\n;\r\nrun;\r\nproc sgplot data=snow1; vbar source \/ freq=deaths datalabel;\r\nFORMAT source SLICE. ;\r\nrun;\r\n\r\n[table id=5 \/]\r\n\r\nIn the following program we added error bars based on 95% confidence interval calculations to each vertical bar. The SAS code is annotated with comments throughout.\r\n<div class=\"textbox textbox--exercises\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">SAS Program to Create Vertical Bar Chart with error bars<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\nproc format;\r\nvalue cndfmt 1 = 'Baseline' 2 = 'Exam'\u00a0 3 = 'Blood Work' 4 = 'Scale';\r\ndata behave;\r\ninput Code Cond bhvscr @@;\r\nxvar=cond; yvar=bhvscr;\r\nlabel xvar='Measurement Conditions';\r\nlabel yvar='Average number of times behaviour was demonstrated';\r\ndatalines;\r\n01 1 79 01 2 54 01 3 51 01 4 85 02 1 21 02 2 15 02 3 23 02 4 80\r\n03 1 37 03 2 14 03 3 18 03 4 38 04 1 61 04 2 21 04 3 13 04 4 79\r\n05 1 32 05 2 30 05 3 34 05 4 58 06 1 60 06 2 30 06 3 15 06 4 50\r\n07 1 78 07 2 53 07 3 67 07 4 53 08 1 67\u00a0 08 2 42 08 3 47 08 4 48 09 1 41\r\n09 2 10 09 3 28 09 4 28 10 1 72 10 2 52 10 3 33 10 4 24 11 1 62\r\n11 2 21 11 3 60 11 4 47 12 1 44 12 2 46 12 3 54 12 4 52 13 1 32\r\n13 2 11 13 3 25 13 4 32 14 1 39 14 2 37 14 3 12 14 4 36 15 1 55 15 2 20\r\n15 3 23 15 4 49 16 1 62 16 2 22\u00a0 16 3 28 16 4 49 17 1 83 17 2 34\r\n17 3 22 17 4 43 18 1 86 18 2 14 18 3 47 18 4 80 19 1 54 19 2 47 19 3 77\r\n19 4 44 20 1 76 20 2 57 20 3 24 20 4 88 21\u00a0 1 56 21\u00a0 2 14 21 3 18 21 4 59\r\n22 1 37 22 2 43 22 3 39 22 4 75 30 1 28 30 2 13 30 3 15 30 4 81 31 1 94\r\n31 2 31 31 3 69 31 4 90 52 1 90 51 2 55 52 3 26 52 4 70 53 1 48 53 2 14\r\n53 3 29 53 4 53 54 1 47 54 2 29 54 3 24 54 4 34\r\n;\r\n\/* Define the axis characteristics *\/\r\naxis1 offset=(0,70) minor=none;\u00a0 axis2 label=(angle=90);\r\npattern1 color = yellow;\r\n\r\n\/* The term pattern1 refers to the first item to be graphed. If there were two variables being graphed then we we use pattern1 and pattern3.\u00a0 *\/\r\nproc sort; by xvar;\r\nproc gchart data = behave;\r\nvbar xvar\/ type=MEAN errorbar=BOTH clm=95\r\nsumvar=yvar discrete raxis=axis2 cerror=crimson cr=biv;\r\nformat xvar cndfmt.;\r\n\/* Define the title *\/\r\ntitle1 'Average Frequency of Behaviour of Interest with 95% CI Standard Error Bars ';\r\nrun;\r\n\r\n<\/div>\r\n<\/div>\r\n<img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/vbarSE.png\" alt=\"\" class=\"aligncenter size-full wp-image-1553\" width=\"1200\" height=\"900\" \/>\r\n\r\n<hr \/>\r\n\r\n<h1>More Simple Barcharts -- Graphing data as a Frequency Distribution Bar Chart<\/h1>\r\nIn the following examples, we use SAS commands to create a three-dimensional vertical bar chart and a horizontal bar chart with a frequency table of the data. In this SAS code, we include formatting commands for the graphical output \u2013 defining the characteristics of each axis \u2013 prior to having the SAS program read the data set.\r\n\r\n[table id=8 \/]\r\n\r\nUsing the same data from the SAS program above and adding two new AXIS labels we can generate a horizontal bar chart with the frequency values included at the end of each horizontal bar.\u00a0 Notice in both the vertical and horizontal bar charts, the length of the bar is proportional to the value of the frequency.\r\n\r\n[table id=9 \/]\r\n\r\nIn the following example, we return to the HDX dataset to observe the total number of cases of the Ebola virus across selected countries. These data are based on the actual reports of cases and deaths related to the 2014 West Africa Ebola Outbreak.\r\n\r\nSample Data Of Total Cases Of Ebola Virus Across Selected Countries\r\n\r\n[table id=10 \/]\r\n\r\nThe SAS program and corresponding output from the analysis is presented below. Notice that only the data for <em>confirmed, probable <\/em>and<em> suspected<\/em> cases are being used in the dataset. These data represent the summary of counts whereby the units of measurement are the total number of cases and the total number of deaths.\r\n<div class=\"textbox textbox--examples\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">SAS Program to Create a Frequency Distribution for Ebola Outbreak<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n<div>OPTIONS PAGESIZE=60 LINESIZE=80;\r\nDATA GRAPH1;\r\nINPUT COUNTRY $ 1-12 DEF $ 15-23 CASES 26-29;\r\nLABEL DEF='DEFINITION OF CASES';\r\nDATALINES;\r\nGUINEA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 CONFIRMED\u00a0 2384\r\nGUINEA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 PROBABLE\u00a0\u00a0\u00a0 275\r\nGUINEA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 SUSPECTED\u00a0\u00a0\u00a0 36\r\nLIBERIA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0CONFIRMED\u00a0 3108\r\nLIBERIA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0PROBABLE\u00a0\u00a0 1773\r\nLIBERIA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0SUSPECTED\u00a0 3096\r\nSIERRA LEONE\u00a0 CONFIRMED\u00a0 7326\r\nSIERRA LEONE\u00a0 PROBABLE\u00a0\u00a0\u00a0 287\r\nSIERRA LEONE\u00a0 SUSPECTED\u00a0 1796\r\n;\r\nPROC SORT; BY COUNTRY;\r\nPROC FREQ; TABLES COUNTRY\/OUT=CASEPCT; WEIGHT CASES;\r\nRUN;<\/div>\r\n<\/div>\r\n<\/div>\r\n<div>\r\n\r\n<span>The output from the PROC FREQ procedure is shown here.<\/span>\r\n\r\n<\/div>\r\n<div align=\"center\">\r\n<table>\r\n<thead>\r\n<tr>\r\n<td><strong>COUNTRY<\/strong><\/td>\r\n<td><strong>Frequency<\/strong><\/td>\r\n<td><strong>Percent<\/strong><\/td>\r\n<td><strong>Cumulative\r\nFrequency<\/strong><\/td>\r\n<td><strong>Cumulative\r\nPercent<\/strong><\/td>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td><strong>GUINEA<\/strong><\/td>\r\n<td>2695<\/td>\r\n<td>13.42<\/td>\r\n<td>2695<\/td>\r\n<td>13.42<\/td>\r\n<\/tr>\r\n<tr>\r\n<td><strong>LIBERIA<\/strong><\/td>\r\n<td>7977<\/td>\r\n<td>39.72<\/td>\r\n<td>10672<\/td>\r\n<td>53.14<\/td>\r\n<\/tr>\r\n<tr>\r\n<td><strong>SIERRA LEONE<\/strong><\/td>\r\n<td>9409<\/td>\r\n<td>46.86<\/td>\r\n<td>20081<\/td>\r\n<td>100.00<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\nIn the code above we produce an output file that represents the percent value of the cases based on the sum of cases in each country. For example, all of the cases for GUINEA regardless of whether the cases were\u00a0 PROBABLE, SUSPECTED, or CONFIRMED, equal 2695 which represents 13.42 percent of the total number of cases. The total number of cases across all countries is reported in the last row of the <strong>Cumulative Frequency<\/strong> column and is 20081.\r\n\r\nBelow, the output data file (DATA=CASEPCT) is used in a PROC GCHART procedure to produce a horizontal bar chart using the SUMVAR option with the data from the PERCENT column.\r\n<table border=\"0\" bgcolor=\"#ffb833\">\r\n<tbody>\r\n<tr>\r\n<td><span>PROC FORMAT; PICTURE PCTFMT (ROUND) 0-HIGH='000%';<\/span>\r\n\r\n<span>PROC GCHART DATA=CASEPCT; HBAR COUNTRY\/ SUMVAR = PERCENT;<\/span>\r\n\r\n<span>FORMAT PERCENT PCTFMT.;<\/span>\r\n\r\n<span>RUN;<\/span><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/casepct.png\" alt=\"\" class=\"aligncenter wp-image-1378\" width=\"825\" height=\"264\" \/>\r\n\r\n<hr \/>\r\n\r\n<h1>Creating a Line Graph to Summarize Data<\/h1>\r\nIn this program, we will use the SAS PROC GPLOT functions to observe \u201cat a glance\u201d a comparison of the unadjusted differences in life expectancy at birth for males versus females in Canada, based on data reported since 1994. The data used in this example range from an initial value of 74.9 years for males and 80.9 years for females in 1994, to life expectancy scores of 79.8 years for males and 83.9 years for females, in 2015. Here we see that at each year of reporting life expectancy estimates, the females are predicted to live longer than males, on average.\r\n\r\n<img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/lifeExp.png\" alt=\"\" class=\"aligncenter wp-image-453 size-full\" width=\"640\" height=\"480\" \/>\r\n<div class=\"textbox textbox--exercises\"><header class=\"textbox__header\">\r\n<h4><span style=\"color: #ffffff\">SAS SGPLOT to Produce Comparison of Life Expectancy Scores<\/span><\/h4>\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\nPROC FORMAT;\r\nVALUE $SXFMT 'F'='FEMALE' 'M'='MALE';\r\nVALUE YRFMT 1='1994\/1995' 2='1998\/1999' 3='2001' 4='2005' 5='2009\/2010' 6='2015';\r\nVALUE SRCFMT 1='UNADJUSTED LIFE EXPECTANCY' 2='HEALTH ADJUSTED LIFE EXPECTANCY';\r\n\r\nLABEL SCORE= 'LIFE EXPECTANCY AT BIRTH';\r\nLABEL YEAR= 'YEAR OF REPORTING';\r\n\r\nDATA CH7FIG1;\r\nINPUT ID SEX $ YEAR SOURCE SCORE @@;\r\nDATALINES;\r\n01 M 1 1 74.9 02 M 2 1 76.0 03 M 3 1 76.9 04 M 4 1 77.9 05 M 5 1 79.1 \u00a0M 06 6 1 79.8 07 M 1 2 65.0 08 M 2 2 67.4 09 M 3 2 67.3 10 M 4 2 68.1\r\n11 M 5 2 69.3 12 M 6 2 69.0 13 F 1 1 80.9 14 F 2 1 81.4 15 F 3 1 81.9\r\n16 F 4 1 82.6 17 F 5 1 83.5 18 F 6 1 83.9 19 F 1 2 67.8 20 F 2 2 70.1\r\n21 F 3 2 69.8 22 F 4 2 70.6 23 F 5 2 71.3 24 F 6 2 70.5\r\n;\r\nTITLE2 'COMPARISON OF LIFE EXPECTANCY AT BIRTH (FEMALES VS MALES)';\r\n\r\nFOOTNOTE1 J=L \" SOURCE: STATS CANADA CATALOGUE NO. 82-003-X ISSN 1209-1367\";\r\n\r\nAXIS1 ORDER=(1990 TO 2015 BY 5) OFFSET=(2,2) LABEL=NONE\r\nMAJOR=(HEIGHT=2) MINOR=(HEIGHT=1) ;\r\n\r\nAXIS2 ORDER=(50 TO 100 BY 5) OFFSET=(0,0) LABEL=NONE\r\nMAJOR=(HEIGHT=2) MINOR=(HEIGHT=1);\r\n\r\nLEGEND1 LABEL=NONE POSITION=(TOP CENTER INSIDE)\r\nMODE=SHARE;\r\n\r\nRUN;\r\nPROC SORT; BY SEX;\r\nPROC SGPLOT;\r\n\r\nSERIES X = YEAR Y = SCORE\/GROUP=SEX lineattrs=(thickness=4);\r\n\r\nXAXIS TYPE = DISCRETE;\r\nstyleattrs datacontrastcolors=(RED NAVY)\r\ndatalinepatterns=(SOLID);\r\n\r\nWHERE SOURCE=1 ;\r\n\r\nFORMAT YEAR YRFMT. SOURCE SRCFMT. ;\r\n\r\nRUN;\r\n\r\n<\/div>\r\n<\/div>\r\n<h2>Adding the WHERE command to restrict output<\/h2>\r\nIn the following line graph, we observe the Health Adjusted Life Expectancy, also referred to as HALE data comparison between males and females changes the contours of the lines for the predicted values of the female and male response data. Again these data range from first reports in 1994 taken from the National Population Health Survey and the Canadian Census in 1993 to 1995 to data from the Canadian Community Health Survey, as well as the NPHS and Census up to and including 2015 (Bushnik, Tjepkema, Martel, 2018)<a href=\"#_ftn1\">[1]<\/a>.\r\n\r\n<img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/HALE.png\" alt=\"\" class=\"aligncenter wp-image-455 size-full\" width=\"640\" height=\"480\" \/>\r\n\r\nThe SAS program to produce the line graph above includes the <strong>PROC SGPLOT<\/strong> statement and the command\u00a0 <strong>WHERE SOURCE=1<\/strong>;\u00a0 This restricts the processing of the graphing procedure to only select the unadjusted life expectancy values from the dependent variable <strong>SCORE<\/strong>. When we change the command <strong>WHERE SOURCE=2<\/strong>; then we change the output to only consider health adjusted values from the dependent variable SCORE.\r\n\r\nHere we use the PROC FORMAT feature to ensure that the data are converted to explanatory labels and these labels are included in the graphs.\r\n<div class=\"textbox textbox--exercises\"><header class=\"textbox__header\">\r\n<h4><span style=\"color: #ffffff\">SAS SGPLOT to produce Health Adjusted Comparison of Life Expectancy Scores<\/span><\/h4>\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\nThis program is incorporating the WHERE command to restrict output to a subgroup.\r\n\r\nPROC SORT; BY SEX;\r\nPROC SGPLOT; SERIES X = YEAR Y = SCORE\/GROUP=SEX\r\nlineattrs=(thickness=4);XAXIS TYPE = DISCRETE;\r\nstyleattrs datacontrastcolors=(RED BLUE)\r\ndatalinepatterns=(SOLID);\r\nWHERE SOURCE=2 ;\r\n\r\nFORMAT YEAR YRFMT. SOURCE SRCFMT. ;\r\n\r\nRUN;\r\n\r\n<\/div>\r\n<\/div>\r\n<div>\r\n<div>\r\n\r\n<a href=\"#_ftnref1\">[1]<\/a>Bushnik, T., Tjepkema, M., &amp; Martel, L., Health-adjusted life Expectancy in Canada, Statistics Canada. Catalogue no. 82-003-X ISSN 1209-1367\r\n\r\n<\/div>\r\nLet's add one more line graph here to show the comparison of the number of reported cases for COVID-19 for the months of August and September in Canada. Note, the PROC SORT command is extremely important here.\r\n\r\nThe SAS program and corresponding output are shown below.\r\n<div class=\"textbox\">\r\n\r\nPROC FORMAT;\r\nVALUE $MNFMT 08=\u2019August\u2019 09=\u2019September\u2019;\r\nDATA A3Q1C;\r\nINPUT MONTH DAY CASES @@;\r\nTITLE2 \u2018NUMBER OF CORONAVIRUS CASES IN THE MONTHS OF AUGUST AND SEPTEMBER 2020\u2019;\r\nLABEL CASES= \u2018NUMBER OF CASES\u2019;\r\nLABEL DAY= \u2018DAY OF REPORTING\u2019;\r\nDATALINES;\r\n08 01 319 08 08 326 08 15 342 08 22 389 08 29 425\r\n08 02 322 08 09 314 08 16 364 08 23 379 08 30 508\r\n08 03 414 08 10 425 08 17 505 08 24 548 08 31 614\r\n08 04 414 08 11 425 08 18 401 08 25 571\r\n08 05 368 08 12 378 08 19 409 08 26 539\r\n08 06 336 08 13 363 08 20 414 08 27 444\r\n08 07 363 08 14 340 08 21 401 08 28 540\r\n09 01 705 09 09 922 09 15 1283 09 22 1792 09 29 2157\r\n09 02 681 09 09 938 09 16 1294 09 23 1812 09 30 2160\r\n09 03 599 09 10 901 09 17 1234 09 24 1843\r\n09 04 687 09 11 898 09 18 1336 09 25 2010\r\n09 05 641 09 12 955 09 19 1236 09 26 1753\r\n09 06 656 09 13 923 09 20 1265 09 27 1873\r\n09 07 767 09 14 1210 09 21 1746 09 28 2350\r\n;\r\n\r\nTITLE2 \u2018COMPARISON OF CASES BY MONTHS (AUGUST AND SEPTEMBER)\u2019;\r\nFOOTNOTE1 J=L \"see source code for data reference -- HEALTH INFOBASE CANADA\";\r\n\/*\r\n* https:\/\/health-infobase.canada.ca\/covid-19\/epidemiological-summary-covid-19-cases.html\r\n*\/\r\nAXIS1 ORDER=(1 TO 31 BY 1) OFFSET=(22) LABEL=NONE MAJOR=(HEIGHT=2) MINOR=(HEIGHT=1) ;\r\n\r\nAXIS2 ORDER=(100 TO 2500 BY 100) OFFSET=(00) LABEL=NONE MAJOR=(HEIGHT=2) MINOR=(HEIGHT=1);\r\n\r\nLEGEND1 LABEL=NONE POSITION=(TOP CENTER INSIDE) MODE=SHARE;\r\n\r\nRUN;\r\nPROC SORT; BY DAY;\r\nPROC SGPLOT;\r\nSERIES X = DAY Y = CASES \/ GROUP=MONTH lineattrs=(thickness=4);\r\nFORMAT MONTH MNFMT. ;\r\nXAXIS TYPE = DISCRETE;\r\nstyleattrs datacontrastcolors=(RED NAVY)\r\ndatalinepatterns=(SOLID);\r\n\r\nRUN;\r\n\r\n<\/div>\r\n<div class=\"textbox textbox--examples\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">Plotting Coronq Virus cases: Data for Canada Months of August and September<\/p>\r\n\r\n<\/header><\/div>\r\n<img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/c19casesbymonth.png\" alt=\"\" class=\"aligncenter size-full wp-image-2106\" width=\"640\" height=\"480\" \/>\r\n<div>\r\n\r\n<hr \/>\r\n\r\n<h1>Creating a Pie Chart to Represent Summary Data<\/h1>\r\nIn the following example, we present a pie chart of the data from The Humanitarian Data Exchange (url: https:\/\/data.hdx.rwlabs.org\/) a project from the United Nations Office for the Coordination of Humanitarian Aid (url: http:\/\/www.unocha.org\/).\r\n\r\nOn January 15th, 2016 the World Health Organization declared the country of Sierra Leone as Ebola-free. However, by that time Sierra Leone had recorded approximately 4000 deaths from the Ebola Virus. In this second example, we will generate a pie chart. The data are based on confirmed cases of Ebola for Sierra Leone by region from 2014 to December 28, 2014. The data represent the cumulative deaths since the recognized beginning of the Ebola virus outbreak in April 2014.\r\n\r\n[table id=6 \/]\r\n\r\n<hr \/>\r\n\r\n<h1>Producing Bubble Plots<\/h1>\r\nSOURCE: HDX: The Humanitarian Data Exchange <a href=\"#_ftn1\">[1]<\/a>\r\n\r\nIn the following example data set the cumulative number of health-care workers deaths by Ebola Disease Virus are reported. These data were extracted from WHO: Ebola Response Roadmap Situation Reports, the data are based on extraction from data reported on 24 December 2014. Here we can plot the total deaths from these data by country, and within each country by month and use appropriate axes titles and legend. The data are presented first in the table below and then as two separate bubble plots. The size of the bubbles represents the frequency value for the total number of deaths reported.\r\n\r\n[table id=11 \/]\r\n\r\nThe SAS program to analyze these data is presented below. Notice that the dataset presented above used three columns: Country, Total Deaths, and Months, which are repeated three times, using the following input statement.\u00a0 The double trailing @@ symbols hold the pointer at the end of the line to ensure that the data read as three variables repeated three times.\r\n\r\nSample Code:\r\n<div>\r\n\r\n\u00a0<span style=\"color: #0000ff\">\u00a0 INPUT COUNTRY $ TOTDTH MONTH $ @@;<\/span>\r\n\r\n<\/div>\r\nIn this way, the SAS program reads the data and produces the output for the entire dataset. Notice that we precede the input statement by declaring the length of the contents of the variable <span style=\"color: #0000ff\">COUNTRY<\/span> to be <strong><span style=\"text-decoration: underline\">more than 12 characters<\/span><\/strong> in length.\r\n<div><\/div>\r\n<div>\r\n<div class=\"textbox textbox--examples\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">SAS code to Produce Bubble Chart<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n<div>OPTIONS PAGESIZE=55 LINESIZE=120 CENTER DATE;\r\nDATA GRAPH2;\r\nLENGTH COUNTRY $12.;\r\nINPUT COUNTRY $ TOTDTH MONTH $ @@;\r\nLABEL TOTDTH ='NUMBER OF DEATHS';DATALINES;\r\n&lt;<strong>DATA GOES HERE<\/strong>&gt;<\/div>\r\nSample of the raw data:\r\n<div>Guinea 27 Sept\u00a0 Sierra_Leone 81 Sept Liberia\u00a0 103 Oct\u00a0 Liberia 81 Sept\u00a0 Guinea\u00a0 35 Sept Nigeria 5 Oct\r\nSierra_Leone 31 Sept\u00a0 Liberia 95 Sept Sierra_Leone\u00a0 95 Oct<\/div>\r\n...\r\n<div>;\r\nRUN;\r\nPROC SORT; BY COUNTRY;\r\nPROC FREQ DATA=GRAPH2;WEIGHT TOTDTH; TABLES MONTH*COUNTRY;\r\nRUN;\r\n<strong>* NOTICE THE WEIGHT STATEMENT IS USED WHEN THE RAW DATA ARE SUMS;<\/strong>\r\nPROC SGPLOT DATA=GRAPH2;\r\nTITLE1 'BUBBLE PLOT';\r\nTITLE2 'EXAMPLE 1: TOTAL DEATHS BY COUNTRY';\r\nBUBBLE X = COUNTRY Y = TOTDTH SIZE = TOTDTH \/ GROUP = MONTH TRANSPARENCY = 0.5;\r\nFOOTNOTE1 J=L \"SOURCE: HTTPS:\/\/DATA.HUMDATA.ORG\/DATASET\/NUMBER-OF-HEALTH-CARE-WORKERS-DEATHS-BY-EDV\";PROC SGPLOT DATA=GRAPH2;\r\nTITLE1 'BUBBLE PLOT';\r\nTITLE2 'EXAMPLE 2: TOTAL DEATHS BY MONTH';\r\nBUBBLE X = MONTH Y = TOTDTH SIZE = TOTDTH \/ GROUP = COUNTRY TRANSPARENCY = 0.5; YAXIS GRID\u00a0\u00a0\u00a0 ;\r\nRUN;<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\nThe summary frequency distribution is presented here first.\r\n<table class=\"grid aligncenter\" style=\"border-collapse: collapse;width: 100%;height: 711px\" border=\"0\">\r\n<thead>\r\n<tr class=\"shaded\" style=\"height: 15px\">\r\n<td style=\"width: 13.6201%;height: 15px\">Month<\/td>\r\n<td style=\"width: 13.6201%;height: 15px;text-align: center\">Guinea<\/td>\r\n<td style=\"width: 13.7993%;height: 15px;text-align: center\">Liberia<\/td>\r\n<td style=\"width: 13.2616%;height: 15px;text-align: center\">Mali<\/td>\r\n<td style=\"width: 13.9785%;height: 15px;text-align: center\">Nigeria<\/td>\r\n<td style=\"width: 18.8172%;height: 15px;text-align: center\">Sierra_Leone<\/td>\r\n<td style=\"width: 13.6201%;height: 15px;text-align: center\">Total<\/td>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr class=\"border\" style=\"height: 163px\">\r\n<td style=\"width: 13.6201%;height: 163px\">Sept<\/td>\r\n<td style=\"width: 13.6201%;height: 163px;text-align: center\">f= 127\r\n\r\n% total = 2.41\r\n\r\nrow % = 17.79\r\n\r\ncol % = 13.66<\/td>\r\n<td style=\"width: 13.7993%;height: 163px;text-align: center\">f= 1056\r\n\r\n% total =20.02\r\n\r\nrow % = 48.89\r\n\r\ncol % = 41.23<\/td>\r\n<td style=\"width: 13.2616%;height: 163px;text-align: center\">f= 12\r\n\r\n% total =0.23\r\n\r\nrow % = 0.56\r\n\r\ncol % = 85.71<\/td>\r\n<td style=\"width: 13.9785%;height: 163px;text-align: center\">f= 30\r\n\r\n% total =0.57\r\n\r\nrow % = 1.39\r\n\r\ncol % = 35.29<\/td>\r\n<td style=\"width: 18.8172%;height: 163px;text-align: center\">f= 650\r\n\r\n% total\u00a0 =12.32\r\n\r\nrow % = 30.09\r\n\r\ncol % =\u00a0 38.60<\/td>\r\n<td style=\"width: 13.6201%;text-align: center;height: 163px\">f= 2160\r\n\r\n% total =40.96<\/td>\r\n<\/tr>\r\n<tr style=\"height: 163px\">\r\n<td style=\"width: 13.6201%;height: 163px\">Oct<\/td>\r\n<td style=\"width: 13.6201%;height: 163px\">f= 124\r\n\r\n% total = 2.35\r\n\r\nrow % = 16.49\r\n\r\ncol % = 13.33<\/td>\r\n<td style=\"width: 13.7993%;height: 163px\">f= 322\r\n\r\n% total = 6.11\r\n\r\nrow % = 42.82\r\n\r\ncol % = 12.57<\/td>\r\n<td style=\"width: 13.2616%;height: 163px\">f= 0\r\n\r\n% total = 0.00\r\n\r\nrow % = 0.00\r\n\r\ncol % = 0.00<\/td>\r\n<td style=\"width: 13.9785%;height: 163px\">f= 15\r\n\r\n% total = 0.28\r\n\r\nrow % = 1.99\r\n\r\ncol % = 17.65<\/td>\r\n<td style=\"width: 18.8172%;height: 163px\">f= 291\r\n\r\n% total =\u00a0 5.52\r\n\r\nrow % = 38.70\r\n\r\ncol % =\u00a0 \u00a0 17.28<\/td>\r\n<td style=\"width: 13.6201%;height: 163px\">f= 752\r\n\r\nrow % = 14.26\r\n\r\n&nbsp;<\/td>\r\n<\/tr>\r\n<tr style=\"height: 148px\">\r\n<td style=\"width: 13.6201%;height: 148px\">Nov<\/td>\r\n<td style=\"width: 13.6201%;height: 148px\">f= 267\r\n\r\n% total = 5.06\r\n\r\nrow % = 16.20\r\n\r\ncol % = 28.71<\/td>\r\n<td style=\"width: 13.7993%;height: 148px\">f= 835\r\n\r\n% total = 15.83\r\n\r\nrow % = 50.67\r\n\r\ncol % = 32.60<\/td>\r\n<td style=\"width: 13.2616%;height: 148px\">f= 2\r\n\r\n% total = 0.04\r\n\r\nrow % = 0.12\r\n\r\ncol % = 14.29<\/td>\r\n<td style=\"width: 13.9785%;height: 148px\">f= 25\r\n\r\n% total = 0.47\r\n\r\nrow % = 1.52\r\n\r\ncol % = 29.41<\/td>\r\n<td style=\"width: 18.8172%;height: 148px\">f= 519\r\n\r\n% total =\u00a0 9.84\r\n\r\nrow % =\u00a0 31.49\r\n\r\ncol % =\u00a0 \u00a030.82<\/td>\r\n<td style=\"width: 13.6201%;height: 148px\">f= 1648\r\n\r\nrow % =31.25\r\n\r\n&nbsp;<\/td>\r\n<\/tr>\r\n<tr style=\"height: 148px\">\r\n<td style=\"width: 13.6201%;height: 148px\">Dec<\/td>\r\n<td style=\"width: 13.6201%;height: 148px\">f= 412\r\n\r\n% total = 7.81\r\n\r\nrow % = 19.07\r\n\r\ncol % = 44.30<\/td>\r\n<td style=\"width: 13.7993%;height: 148px\">f= 1056\r\n\r\n% total = 20.02\r\n\r\nrow % = 48.89\r\n\r\ncol % = 41.23<\/td>\r\n<td style=\"width: 13.2616%;height: 148px\">f= 12\r\n\r\n% total = 0.23\r\n\r\nrow % = 0.56\r\n\r\ncol % = 85.71<\/td>\r\n<td style=\"width: 13.9785%;height: 148px\">f= 30\r\n\r\n% total = 0.57\r\n\r\nrow % = 1.39\r\n\r\ncol % = 35.29<\/td>\r\n<td style=\"width: 18.8172%;height: 148px\">f= 650\r\n\r\n% total = 12.32\r\n\r\nrow % = 30.09\r\n\r\ncol % =\u00a0 38.60<\/td>\r\n<td style=\"width: 13.6201%;height: 148px\">f= 2160\r\n\r\nrow % = 40.96\r\n\r\n&nbsp;<\/td>\r\n<\/tr>\r\n<tr style=\"height: 74px\">\r\n<td style=\"width: 13.6201%;height: 74px\">Total<\/td>\r\n<td style=\"width: 13.6201%;height: 74px\">f= 930\r\n\r\ncol % = 17.63<\/td>\r\n<td style=\"width: 13.7993%;height: 74px\">f= 2561\r\n\r\ncol % = 48.56<\/td>\r\n<td style=\"width: 13.2616%;height: 74px\">f= 14\r\n\r\ncol % = 0.27<\/td>\r\n<td style=\"width: 13.9785%;height: 74px\">f= 85\r\n\r\ncol % = 1.61<\/td>\r\n<td style=\"width: 18.8172%;height: 74px\">f= 1684\r\n\r\ncol % =\u00a0 \u00a031.93<\/td>\r\n<td style=\"width: 13.6201%;height: 74px\">f= 5274\r\n\r\n100.00<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\nBubble plots can be used to illustrate the distribution of outcomes within specific groups.\u00a0 In the following two graphs the data from the summary frequency table of <em>month by country<\/em> above, which showed deaths within the countries monitored across months are presented using two different grouping strategies. In the first example (bubble plot example 1) the data showing the number of deaths (Y-axis) are separated using countries as the main X-Axis variable and months as the grouping variable.\r\n\r\n<img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble1.png\" alt=\"\" class=\"aligncenter size-full wp-image-1408\" width=\"1337\" height=\"1004\" \/>The specific SAS code is:\r\n<div>\r\n<div class=\"textbox shaded\">PROC SGPLOT DATA=GRAPH2;\r\nTITLE1 'BUBBLE PLOT';\r\nTITLE2 'EXAMPLE 1: TOTAL DEATHS BY COUNTRY';\r\nBUBBLE X = COUNTRY Y = TOTDTH SIZE = TOTDTH \/ GROUP = MONTH TRANSPARENCY = 0.5;FOOTNOTE1 J=L \"SOURCE: HTTPS:\/\/DATA.HUMDATA.ORG\/DATASET\/NUMBER-OF-HEALTH-CARE-WORKERS-DEATHS-BY-EDV\";<\/div>\r\n<\/div>\r\nIn the second example (bubble plot example 2) the data showing the number of deaths (Y-axis) are separated using months as the main X-axis variable and country in which the deaths occurred is the grouping variable.\r\n\r\n<img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble2.png\" alt=\"\" class=\"aligncenter size-full wp-image-1410\" width=\"1187\" height=\"889\" \/>\r\n\r\nThe specific SAS code is presented here. Notice we did not need to repeat the footnote statement from Bubble Plot 1 for it to be included in Bubble Plot 2 because the RUN; statement was held until the end of the program.\r\n<div>\r\n<div class=\"textbox shaded\">PROC SGPLOT DATA=GRAPH2;\r\nTITLE1 'BUBBLE PLOT';\r\nTITLE2 'EXAMPLE 2: TOTAL DEATHS BY MONTH';\r\nBUBBLE X = MONTH Y = TOTDTH SIZE = TOTDTH \/ GROUP = COUNTRY TRANSPARENCY = 0.5; YAXIS GRID\u00a0\u00a0\u00a0 ;\r\nRUN;<\/div>\r\n<\/div>\r\n\r\n<hr \/>\r\n\r\n<h1>Producing Star Charts<\/h1>\r\nIn this SAS graphing procedure we show how out of balance sedentary behaviour can be in comparison to other activities of daily living.\r\n\r\nPrimary healthcare has continued to support the notion that sedentary behaviours are major risk factors for most chronic diseases.\u00a0 In particular, there has been a growing awareness of the relationship between sitting for prolonged periods during the day as a risk factor for chronic diseases such as CVD\/CHD, type II diabetes, and hypertension. The data reported here is the estimated time in non-standing related activities. We can use a star chart to demonstrate an effective approach to representing unbalanced data for a given outcome. These data are from the American Heart Foundation (2015).\r\n\r\nThe SAS code to generate a horizontal bar chart with a corresponding frequency distribution table and two different star graphs are shown below. Notice in this SAS code we predefine the length of the input data for the variable BEHAVIOR and we use a fixed input format to enter the data values for the variables TIME in columns 22 to 24 and the variable GROUP in columns 27 to 28.\r\n<div class=\"textbox shaded\">\r\n\r\nDATA STARS;\r\nLENGTH BEHAV $20.;\r\nINPUT BEHAV $ 1-20 TIME 22-24 GRP 27-28 ;\r\nLABEL TIME='TIME (HOURS)';\u00a0 LABEL BEHAV='BEHAVIOUR';\r\nDATALINES;\r\nMORNING_WALK\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.5\u00a0 1\r\nDRIVE_TO_WORK\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.0\u00a0 1\r\nAM_COMPUTER_TIME\u00a0\u00a0\u00a0\u00a0 4.0\u00a0 1\r\nLUNCHTIME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.5\u00a0 1\r\nPM_COMPUTER_TIME\u00a0\u00a0\u00a0\u00a0 4.0\u00a0 1\r\nDRIVE_HOME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.0\u00a0 2\r\nSTRENGTH_TRAINING\u00a0\u00a0\u00a0 0.5\u00a0 2\r\nDINNERTIME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.5\u00a0 2\r\nRELAX_TV_OR_READ\u00a0\u00a0\u00a0\u00a0 4.0\u00a0 2\r\nBEDTIME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8.0\u00a0 2\r\n;\r\nPROC GCHART;\r\nHBAR BEHAV\/SUMVAR=TIME;\r\nTITLE1 \"HOURS SPENT IN SEDENTARY BEHAVIOUR-HORIZONTAL BAR CHART\";\r\nRUN;\r\n\r\nPROC GCHART ;\r\nTITLE1 \"EXAMPLE STAR GRAPH 1\";\r\nTITLE2 \"HOURS SPENT IN SEDENTARY BEHAVIOUR\";\r\nSTAR BEHAV \/ DISCRETE SUMVAR=TIME FILL=S;\r\nRUN;\r\n\r\nPROC GCHART ;\r\nSTAR BEHAV \/ DISCRETE SUMVAR=TIME NOCONNECT;\r\nTITLE1 \"EXAMPLE STAR GRAPH 2\";\r\nTITLE2 \"HOURS SPENT IN SEDENTARY BEHAVIOUR\";\r\nRUN;\r\n\r\n<\/div>\r\n<img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star1.png\" alt=\"\" class=\"aligncenter size-full wp-image-1414\" width=\"1110\" height=\"833\" \/>\r\n<div class=\"textbox textbox--exercises\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">In the image above we include the FILL=S; option in the SAS code<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">PROC GCHART ;\r\nTITLE1 \"EXAMPLE STAR GRAPH 1\";\r\nTITLE2 \"HOURS SPENT IN SEDENTARY BEHAVIOUR\";\r\nSTAR BEHAV \/ DISCRETE SUMVAR=TIME FILL=S;<\/div>\r\n<\/div>\r\n<img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star2.png\" alt=\"\" class=\"aligncenter size-full wp-image-1415\" width=\"1122\" height=\"818\" \/>\r\n\r\n<\/div>\r\n&nbsp;\r\n<div class=\"textbox textbox--exercises\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">In the image above we <em>we <strong>remove<\/strong> the <\/em><em>FILL=S<\/em><em> option and <strong>include<\/strong> the <\/em><em>NOCONNECT <\/em><em>option <\/em>in the SAS code<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">PROC GCHART ;\r\nSTAR BEHAV \/ DISCRETE SUMVAR=TIME NOCONNECT;\r\nTITLE1 \"EXAMPLE STAR GRAPH 2\";\r\nTITLE2 \"HOURS SPENT IN SEDENTARY BEHAVIOUR\";<\/div>\r\n<\/div>\r\n<div>\r\n\r\n<hr \/>\r\n\r\n<h1>Preparing data for graphing by transposing datasets<\/h1>\r\nIn this next section, we will rotate the perspective of the data set -- a term we refer to as TRANSPOSING.\u00a0 With the PROC TRANSPOSE feature, we can re-orient the data set from written in a wide format to a narrow format.\r\n\r\nThe wide-format of the dataset is shown in the table below. With the SAS code below we can transpose four variables into one variable. The following table is the original four variables from the raw data.\r\n<div align=\"center\">\r\n<table>\r\n<thead>\r\n<tr>\r\n<td>Obs<\/td>\r\n<td>ID<\/td>\r\n<td>var1<\/td>\r\n<td>var2<\/td>\r\n<td>var3<\/td>\r\n<td>var4<\/td>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>1<\/td>\r\n<td>7<\/td>\r\n<td>0.350<\/td>\r\n<td>0.326<\/td>\r\n<td>0.333<\/td>\r\n<td>0.333<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>2<\/td>\r\n<td>9<\/td>\r\n<td>0.346<\/td>\r\n<td>0.328<\/td>\r\n<td>0.318<\/td>\r\n<td>0.325<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>3<\/td>\r\n<td>10<\/td>\r\n<td>0.350<\/td>\r\n<td>0.352<\/td>\r\n<td>0.345<\/td>\r\n<td>0.355<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>4<\/td>\r\n<td>11<\/td>\r\n<td>0.345<\/td>\r\n<td>0.330<\/td>\r\n<td>0.341<\/td>\r\n<td>0.321<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>5<\/td>\r\n<td>13<\/td>\r\n<td>0.348<\/td>\r\n<td>0.342<\/td>\r\n<td>0.335<\/td>\r\n<td>0.330<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>6<\/td>\r\n<td>14<\/td>\r\n<td>0.347<\/td>\r\n<td>0.334<\/td>\r\n<td>0.342<\/td>\r\n<td>0.350<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>7<\/td>\r\n<td>15<\/td>\r\n<td>0.349<\/td>\r\n<td>0.325<\/td>\r\n<td>0.324<\/td>\r\n<td>0.327<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>8<\/td>\r\n<td>16<\/td>\r\n<td>0.338<\/td>\r\n<td>0.322<\/td>\r\n<td>0.334<\/td>\r\n<td>0.324<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>9<\/td>\r\n<td>18<\/td>\r\n<td>0.331<\/td>\r\n<td>0.329<\/td>\r\n<td>0.314<\/td>\r\n<td>0.335<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>10<\/td>\r\n<td>19<\/td>\r\n<td>0.342<\/td>\r\n<td>0.332<\/td>\r\n<td>0.323<\/td>\r\n<td>0.328<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>11<\/td>\r\n<td>20<\/td>\r\n<td>0.338<\/td>\r\n<td>0.318<\/td>\r\n<td>0.325<\/td>\r\n<td>0.331<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div>\r\n<div class=\"textbox textbox--examples\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">SAS Code to transpose the data from a wide to a narrow format<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\nDATA TRNSPS_W2N;\r\n\/* TRANSPOSING WIDE DATA TO NARROW DATA *\/\r\nINPUT ID VAR1 VAR2 VAR3 VAR4;\r\nDATALINES;\r\n7 0.35 0.326 0.333 0.333\r\n9 0.346 0.328 0.318 0.325\r\n10 0.35 0.352 0.345 0.355\r\n11 0.345 0.33 0.341 0.321\r\n13 0.348 0.342 0.335 0.33\r\n14 0.347 0.334 0.342 0.35\r\n15 0.349 0.325 0.324 0.327\r\n16 0.338 0.322 0.334 0.324\r\n18 0.331 0.329 0.314 0.335\r\n19 0.342 0.332 0.323 0.328\r\n20 0.338 0.318 0.325 0.331\r\n;\r\n\r\nTITLE1 'TRANSPOSING FOUR VARIABLES INTO ONE VARIABLE';\r\nPROC SORT DATA=TRNSPS_W2N; BY ID;\r\nTITLE2 'PRINT OF THE ORIGINAL FOUR VARIABLES FROM THE RAW DATA';\r\nPROC PRINT; VAR ID VAR1 VAR2 VAR3 VAR4 ;\r\nRUN;\r\nPROC TRANSPOSE DATA=TRNSPS_W2N OUT=NARROW;\r\nBY ID;\r\n\r\nTITLE2 'PRINT OF THE TRANSPOSED DATA TO A SINGLE VARIABLE';\r\nRUN;\r\nPROC PRINT DATA=NARROW; VAR ID \u00a0\u00a0 _NAME_ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 COL1;\r\nRUN;\r\n\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\nA portion of the narrow format of the data is shown here in this printout of the transposed data. Here we show the four variables as one categorical variable and one outcome variable, which can then be graphed.\r\n\r\n<\/div>\r\n<\/div>\r\n<div>\r\n<div>\r\n<div align=\"center\">\r\n<table>\r\n<thead>\r\n<tr>\r\n<td>Obs<\/td>\r\n<td>ID<\/td>\r\n<td>_NAME_<\/td>\r\n<td>COL1<\/td>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>1<\/td>\r\n<td>7<\/td>\r\n<td>var1<\/td>\r\n<td>0.350<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>2<\/td>\r\n<td>7<\/td>\r\n<td>var2<\/td>\r\n<td>0.326<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>3<\/td>\r\n<td>7<\/td>\r\n<td>var3<\/td>\r\n<td>0.333<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>4<\/td>\r\n<td>7<\/td>\r\n<td>var4<\/td>\r\n<td>0.333<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>5<\/td>\r\n<td>9<\/td>\r\n<td>var1<\/td>\r\n<td>0.346<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>6<\/td>\r\n<td>9<\/td>\r\n<td>var2<\/td>\r\n<td>0.328<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>7<\/td>\r\n<td>9<\/td>\r\n<td>var3<\/td>\r\n<td>0.318<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>8<\/td>\r\n<td>9<\/td>\r\n<td>var4<\/td>\r\n<td>0.325<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>9<\/td>\r\n<td>10<\/td>\r\n<td>var1<\/td>\r\n<td>0.350<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\nThe data in the transposed table above can be used in a graph to show the response of each participant for the single dependent variable, which we called SCORE, across four measures. The SGPLOT procedure was modified from SAS SUPPORT CODE: Sample <em>50217: <\/em>Plot means with standard error bars from calculated data for groups with PROC GPLOT<a href=\"#_ftn1\">[1]<\/a>.\r\n<div class=\"textbox textbox--examples\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">SAS Code for Wide to Narrow<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n<div>\r\n\r\nPROC FORMAT;\r\nVALUE CNDFMT 1 = 'CONDITION 1'\r\n2 = 'CONDITION 2'\r\n3 = 'CONDITION 3'\r\n4 = 'CONDITION 4' ;\r\n\r\n\/* PLOT OF DEPENDENT VARIABLE AFTER TRANSPOSE TO NARROW DATA *\/\r\nDATA W2N;\r\nINPUT OBS ID COND SCORE;\r\n\/* USE THE TRANSPOSED DATASET IN A LINE GRAPH ACROSS 4 CONDITIONS *\/\r\nDATALINES;\r\n1 7\u00a0 1 0.350\r\n2 7\u00a0 2 0.326\r\n\r\n&lt;MORE DATA HERE &gt;\r\n\r\n41 20\u00a0 1 0.338\r\n42 20\u00a0 2 0.318\r\n43 20\u00a0 3 0.325\r\n44 20 \u00a04 0.331\r\n;\r\nTITLE1 'TRANSPOSING FOUR VARIABLES INTO ONE VARIABLE';\r\nTITLE2 'TRANSPOSED VARIABLE AS A SINGLE RESPONSE ACROSS FOUR TIME POINTS';\r\nAXIS1 ORDER=(1 TO 4 BY 0.55) OFFSET=(2,2)\r\nLABEL=NONE\u00a0 MAJOR=(HEIGHT=2) MINOR=(HEIGHT=1);\r\nAXIS2 ORDER=(0.3 TO 0.4 BY 0.01) OFFSET=(0,0)\r\nLABEL=NONE\u00a0\u00a0 MAJOR=(HEIGHT=2) MINOR=(HEIGHT=1);\r\nRUN;\r\nPROC SORT DATA=W2N; BY COND;\r\nPROC MEANS DATA=W2N\u00a0 NOPRINT;\r\nBY COND;\r\nVAR SCORE;\r\nOUTPUT OUT=MEANSOUT MEAN=MEAN STDERR=STDERR;\r\nTITLE1 'DESCRIPTIVE STATISTICS FOR SCORE ACROSS 4 CONDITIONS';\r\nRUN;\r\n\/* RESHAPE THE DATA TO PRESENT ONE Y VALUE FOR *\/\r\n\/* EACH X FOR USE WITH THE HILOC INTERPOLATION.\u00a0\u00a0 *\/\r\nDATA RESHAPE(KEEP=COND SCORE MEAN);\r\nSET MEANSOUT;\r\nSCORE=MEAN;\r\nOUTPUT;\r\nSCORE=MEAN - STDERR;\r\nOUTPUT;\r\nSCORE=MEAN + STDERR;\r\nOUTPUT;\r\nRUN;\r\n\/* DEFINE THE TITLE *\/\r\nTITLE1 'PLOT OF MEANS WITH STANDARD ERROR BARS FOR SCORE ACROSS CONDITIONS';\r\n\/* DEFINE THE AXIS CHARACTERISTICS *\/\r\nAXIS1 OFFSET=(5,5) MINOR=NONE;\r\nAXIS2 LABEL=(ANGLE=90);\r\n\/* DEFINE THE SYMBOL CHARACTERISTICS *\/\r\nSYMBOL1 INTERPOL=HILOCTJ COLOR=BLUE LINE=2;\r\nSYMBOL2 INTERPOL=NONE COLOR=BLUE VALUE=DOT HEIGHT=1.5;\r\n\/* PLOT THE ERROR BARS USING THE HILOCTJ INTERPOLATION *\/\r\n\/* AND OVERLAY SYMBOLS AT THE MEANS. *\/\r\nPROC GPLOT DATA=RESHAPE;\r\nPLOT SCORE*COND MEAN*COND \/ OVERLAY HAXIS=AXIS1 VAXIS=AXIS2;\r\nFORMAT COND CNDFMT.;\r\nRUN;\r\n\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\nThis SAS code from the transposed dataset produced the following graph.\r\n<h2><img src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/wide2n.png\" alt=\"\" class=\"aligncenter size-full wp-image-1424\" width=\"1000\" height=\"750\" \/>Transposing data from narrow to a wide format<\/h2>\r\nConsider now if our data were in a long format, as in a single column with 3 categories but we wanted to reshape the data so that each of the categories became a separate measure of interest.\u00a0 In the following data set consisting of a categorical variable that we called employment status and a dependent variable based on household savings in the bank on January 1. Here, we will transpose the data from a long format to a wide format and convert the initial measure of interest to three variables.\r\n\r\nThe initial SAS code with data is as follows<a href=\"#_ftn2\">[2]<\/a>:\r\n<div>\r\n<div class=\"textbox textbox--examples\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">SAS Code for Narrow to Wide<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\nPROC FORMAT;\r\nVALUE EMP 1= 'FULL-TIME' 2 = 'PART-TIME' 3= 'CASUAL';\r\nDATA EMPSTAT;\r\nLABEL\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ID = 'PARTICIPANT ID'\r\nEMPSTAT = 'EMPLOYMENT STATUS'\r\nSAVINGS = 'SAVINGS IN BANK';\r\nINPUT ID 1-2 EMPSTAT 4 SAVINGS 6-9;\r\nDATALINES;\r\n01 3 0020\r\n02 1 0120\r\n03 2 0050\r\n04 3 0030\r\n05 3 0000\r\n06 1 4500\r\n07 1 8900\r\n08 2 0540\r\n09 3 0900\r\n10 1 3220\r\n11 2 0240\r\n12 2 0400\r\n;\r\nPROC SORT data=EMPSTAT; BY EMPSTAT;\r\nPROC FREQ; TABLES EMPSTAT;\r\nFORMAT EMPSTAT EMP. ;\r\nPROC FREQ; TABLES EMPSTAT*SAVINGS;\r\nFORMAT EMPSTAT EMP. ;\r\nTITLE1 ' FREQUENCY DISTRIBUTION FOR EMPLOYMENT STATUS';\r\nRUN;\r\nPROC SORT data=EMPSTAT; BY ID;\r\nPROC TRANSPOSE data=EMPSTAT out=NEW_WIDE prefix=GROUP_;\r\nby ID ;\r\nid EMPSTAT;\r\nvar SAVINGS;\r\nRUN;\r\nproc print data = NEW_WIDE; VAR ID GROUP_1 GROUP_2 GROUP_3;\r\nTITLE 'OUTPUT FOR WIDE FORMATTED DATA';\r\nRUN;\r\nPROC MEANS MEAN MEDIAN STD STDERR CV; VAR GROUP_1 GROUP_2 GROUP_3;\r\nTITLE 'USING PROC MEANS- DESCRIPTIVE STATISTICS FOR WIDE FORMATTED DATA';\r\nRUN;\r\nPROC TABULATE data = NEW_WIDE;\r\nLABEL GROUP_1 = 'EMPLOYED FULL TIME'\r\nGROUP_2 = 'EMPLOYED PART TIME'\r\nGROUP_3 = 'EMPLOYED CASUALLY';\r\nVAR GROUP_1 GROUP_2 GROUP_3;\r\nTABLE (GROUP_1 GROUP_2 GROUP_3)* (N MEAN STD CV);\r\nTITLE 'USING PROC TABULATE - DESCRIPTIVE STATISTICS FOR WIDE FORMATTED DATA';\r\nRUN;\r\n\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\nThe SAS code above produced the following output after transposing the data from the dependent variable to produce three measures of interest which we called GROUP_1 GROUP_2 and GROUP_3. Each variable now represents the data within the specific employment category and the PROC TABULATE and PROC MEANS commands were used to produce descriptive statistics for each separate dependent measure.\r\n\r\nFREQUENCY DISTRIBUTION FOR EMPLOYMENT STATUS\r\n<table class=\"landscape aligncenter\" style=\"border-collapse: collapse;width: 100%;height: 75px\" border=\"0\">\r\n<thead>\r\n<tr class=\"shaded\" style=\"height: 30px\">\r\n<td style=\"width: 20%;height: 30px;text-align: center\">EMPLOYMENT STATUS<\/td>\r\n<td style=\"width: 20%;height: 30px;text-align: center\">FREQUENCY<\/td>\r\n<td style=\"width: 20%;height: 30px;text-align: center\">PERCENT<\/td>\r\n<td style=\"width: 20%;height: 30px;text-align: center\">CUMULATIVE FREQUENCY<\/td>\r\n<td style=\"width: 20%;height: 30px;text-align: center\">CUMULATIVE PERCENT<\/td>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"height: 15px\">\r\n<td style=\"width: 20%;height: 15px\">FULL TIME<\/td>\r\n<td style=\"width: 20%;height: 15px\">4<\/td>\r\n<td style=\"width: 20%;height: 15px\">33,33<\/td>\r\n<td style=\"width: 20%;height: 15px\">4<\/td>\r\n<td style=\"width: 20%;height: 15px\">33.33<\/td>\r\n<\/tr>\r\n<tr style=\"height: 15px\">\r\n<td style=\"width: 20%;height: 15px\">PART-TIME<\/td>\r\n<td style=\"width: 20%;height: 15px\">4<\/td>\r\n<td style=\"width: 20%;height: 15px\">33.33<\/td>\r\n<td style=\"width: 20%;height: 15px\">8<\/td>\r\n<td style=\"width: 20%;height: 15px\">33.33<\/td>\r\n<\/tr>\r\n<tr style=\"height: 15px\">\r\n<td style=\"width: 20%;height: 15px\">CASUAL<\/td>\r\n<td style=\"width: 20%;height: 15px\">4<\/td>\r\n<td style=\"width: 20%;height: 15px\">33.33<\/td>\r\n<td style=\"width: 20%;height: 15px\">12<\/td>\r\n<td style=\"width: 20%;height: 15px\">100<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\nUSING PROC MEANS TO PRODUCE DESCRIPTIVE STATISTICS FOR WIDE FORMATTED DATA\r\n\r\nThe MEANS Procedure\r\n<div align=\"center\">\r\n<table class=\"lines aligncenter\" style=\"height: 145px\" width=\"439\">\r\n<thead>\r\n<tr class=\"shaded\">\r\n<td style=\"text-align: center;width: 70.25px\">Variable<\/td>\r\n<td style=\"text-align: center;width: 51.85px\">Mean<\/td>\r\n<td style=\"text-align: center;width: 57.45px\">Median<\/td>\r\n<td style=\"text-align: center;width: 51.85px\">Std Dev<\/td>\r\n<td style=\"text-align: center;width: 54.25px\">Std Error<\/td>\r\n<td style=\"text-align: center;width: 73.45px\">Coeff of Variation<\/td>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr class=\"border\">\r\n<td style=\"width: 70.25px;text-align: center\">GROUP_1\r\n\r\nGROUP_2\r\n\r\nGROUP_3<\/td>\r\n<td style=\"width: 51.85px;text-align: center\">4185.00\r\n\r\n307.50\r\n\r\n237.50<\/td>\r\n<td style=\"width: 57.45px;text-align: center\">3860.00\r\n\r\n320.00\r\n\r\n25.00<\/td>\r\n<td style=\"width: 51.85px;text-align: center\">3641.70\r\n\r\n210.93\r\n\r\n441.84<\/td>\r\n<td style=\"width: 54.25px;text-align: center\">1820.85\r\n\r\n105.47\r\n\r\n220.92<\/td>\r\n<td style=\"width: 73.45px;text-align: center\">87.01\r\n\r\n68.60\r\n\r\n186.04<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\nUSING PROC TABULATE \u2013DESCRIPTIVE STATISTICS FOR WIDE FORMATTED DATA\r\n\r\n[table id=14 \/]\r\n<div>\r\n<div>\r\n\r\n<hr \/>\r\n\r\n<a href=\"#_ftnref1\">[1]<\/a> http:\/\/support.sas.com\/kb\/50\/217.html\r\n\r\n<\/div>\r\n<div>\r\n\r\n<a href=\"#_ftnref2\">[2]<\/a> The structure of this code was derived from: Introduction to SAS. UCLA: Statistical Consulting Group.from https:\/\/stats.idre.ucla.edu\/sas\/modules\/sas-learning-moduleintroduction-to-the-features-of-sas\/ (accessed August 22, 2016).\r\n\r\n<\/div>\r\n<\/div>\r\n&nbsp;\r\n<div>\r\n<div>\r\n\r\n<a href=\"#_ftnref1\">[1]<\/a> (URL \u2013 https:\/\/data.humdata.org\/dataset\/number-of-health-care-workers-deaths-by-edv) a project from the United Nations Office for the Coordination of Humanitarian Aid (url: http:\/\/www.unocha.org\/)\r\n\r\n<\/div>\r\n<\/div>\r\n\r\n<hr \/>\r\n\r\n<\/div>\r\n<div><\/div>\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<\/div>","rendered":"<div class=\"textbox textbox--learning-objectives\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Learner Outcomes<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<p>After reading this chapter you should be able to:<\/p>\n<ul>\n<li>Organize data from various sources, and especially identify the specific variables that comprise a data set and separate data into independent and dependent measures.<\/li>\n<li>Present your data in a graphical format to convey your message to the reader by identifying the level of measurement for each of the variables within the data set and organize the data appropriately for the type of graph or table selected<\/li>\n<li>Select from a variety of graphing and charting features in SAS to create an appropriate visual presentation of variables in your dataset and thereby demonstrate when a graph of a particular type is most appropriate<\/li>\n<li>Prepare your data set for graphing and charting by transposing from wide to narrow or narrow to wide<\/li>\n<li>Create a simple SAS program to produce different types of graphs and tables<\/li>\n<li>Add specific features such as axis labels, legends, and colors to enhance your graphical presentation of variables in the data set<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<h2>Preamble<\/h2>\n<p>Producing graphical images is one of the most important features of conveying the statistical message. Face it, statistics is a hard area to wrap your brain around because it is based on the complexity of mathematically derived outcomes. What is the chance of picking the correct lottery number? How many people do I need in my study to know that I can represent the population? What is the best outcome from the randomized clinical trial that I should achieve before I decide that the vaccine is effective? Chance, probability, estimation, hypotheses, confidence, prediction, these are all complex concepts in which we only estimate the likelihood of our accuracy.<\/p>\n<p>Statistics is the science that helps us to create knowledge based on the information attributed to the facts that make up our datasets.<\/p>\n<p>Graphing is an approach that enables us to bring the data from the abstractness of a fact to the reality of a contextualized image. With a graph, we view the image and then interpret the meaning of the image from our understanding of the mathematical system that the image represents.<\/p>\n<p>In applying statistics, and more specifically learning statistics, graphs are essential.<\/p>\n<h2>Creating a Visual Presentation of Your Data<\/h2>\n<p>In this section, we will organize data from various sources, and especially identify the specific variables that comprise a data set and separate data into independent and dependent measures. The examples here will enable us to present data in a graphical format to convey our message to the reader by identifying the level of measurement for each of the variables within the data set and organize the data appropriately for the type of graph or table selected.<\/p>\n<p>Graphing is a useful technique to illustrate:<\/p>\n<ul>\n<li>the shape of data sets relative to how scores are distributed<\/li>\n<li>relationships or associations between variables within or between data sets<\/li>\n<li>the magnitude of differences for numbers within and between datasets<\/li>\n<\/ul>\n<p>In this section, we will use several different examples of graphing and charting features in SAS to create the appropriate visual presentation of variables in our dataset and thereby demonstrate when a graph of a particular type is most appropriate. In addition, we will work through examples that prepare data sets for graphing and charting by transposing from wide to narrow or narrow to wide, as well as adding specific features such as axis labels, legends, and colors to enhance your graphical presentation of variables in the data set.<\/p>\n<h2>Creating a Vertical Bar Chart to Represent John Snow&#8217;s Natural Experiment<\/h2>\n<p><span class=\"tablepress-table-description tablepress-table-description-id-5\">In this first example, we will use the PROC SGPLOT command to create a vertical bar graph to represent the data that John Snow reported for the water source by household in his 1854 surveillance during the London Cholera epidemic. The data are discrete frequencies of households which are then plotted against the source of drinking water for the household. The SAS code used to generate this vertical bar chart is presented below the image.\u00a0<\/span><\/p>\n<p>In this SAS graphing program we create a vertical bar graph to represent the data that John Snow reported for the water source by household in his 1854 surveillance during the London Cholera epidemic. The data are discrete frequencies of households and these are plotted against the source of drinking water for the household.<\/p>\n<p>The SAS Code to generate the Vertical Bar Chart above.<br \/>\noptions pagesize=55 linesize=120 center date;<br \/>\nPROC FORMAT;<br \/>\nVALUE SLICE 1 = &#8216;Southwark &amp;amp; Vauxhall&#8217;<br \/>\n2 = &#8216;Lambeth&#8217;<br \/>\n3 = &#8216;Thames River&#8217;<br \/>\n4 = &#8216;Pumps and Wells&#8217;<br \/>\n5 = &#8216;Ditches&#8217;<br \/>\n6 = &#8216;Unknown&#8217;;<br \/>\ndata snow1;<br \/>\ninput source deaths ;<br \/>\nlabel Source = &#8216;Water Source&#8217;;<br \/>\ndatalines;<br \/>\n1 286<br \/>\n2 14<br \/>\n3 22<br \/>\n4 04<br \/>\n5 04<br \/>\n6 04<br \/>\n;<br \/>\nrun;<br \/>\nproc sgplot data=snow1; vbar source \/ freq=deaths datalabel;<br \/>\nFORMAT source SLICE. ;<br \/>\nrun;<\/p>\n<table id=\"tablepress-5\" class=\"tablepress tablepress-id-5\">\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-1\">\n<td class=\"column-1\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/03\/Snow1.png\" alt=\"\" width=\"1200\" height=\"900\" class=\"aligncenter size-full wp-image-1293\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/03\/Snow1.png 1200w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/03\/Snow1-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/03\/Snow1-1024x768.png 1024w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/03\/Snow1-768x576.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/03\/Snow1-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/03\/Snow1-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/03\/Snow1-350x263.png 350w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/td>\n<\/tr>\n<tr class=\"row-2\">\n<td class=\"column-1\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!-- #tablepress-5 from cache --><\/p>\n<p>In the following program we added error bars based on 95% confidence interval calculations to each vertical bar. The SAS code is annotated with comments throughout.<\/p>\n<div class=\"textbox textbox--exercises\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">SAS Program to Create Vertical Bar Chart with error bars<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<p>proc format;<br \/>\nvalue cndfmt 1 = &#8216;Baseline&#8217; 2 = &#8216;Exam&#8217;\u00a0 3 = &#8216;Blood Work&#8217; 4 = &#8216;Scale&#8217;;<br \/>\ndata behave;<br \/>\ninput Code Cond bhvscr @@;<br \/>\nxvar=cond; yvar=bhvscr;<br \/>\nlabel xvar=&#8217;Measurement Conditions&#8217;;<br \/>\nlabel yvar=&#8217;Average number of times behaviour was demonstrated&#8217;;<br \/>\ndatalines;<br \/>\n01 1 79 01 2 54 01 3 51 01 4 85 02 1 21 02 2 15 02 3 23 02 4 80<br \/>\n03 1 37 03 2 14 03 3 18 03 4 38 04 1 61 04 2 21 04 3 13 04 4 79<br \/>\n05 1 32 05 2 30 05 3 34 05 4 58 06 1 60 06 2 30 06 3 15 06 4 50<br \/>\n07 1 78 07 2 53 07 3 67 07 4 53 08 1 67\u00a0 08 2 42 08 3 47 08 4 48 09 1 41<br \/>\n09 2 10 09 3 28 09 4 28 10 1 72 10 2 52 10 3 33 10 4 24 11 1 62<br \/>\n11 2 21 11 3 60 11 4 47 12 1 44 12 2 46 12 3 54 12 4 52 13 1 32<br \/>\n13 2 11 13 3 25 13 4 32 14 1 39 14 2 37 14 3 12 14 4 36 15 1 55 15 2 20<br \/>\n15 3 23 15 4 49 16 1 62 16 2 22\u00a0 16 3 28 16 4 49 17 1 83 17 2 34<br \/>\n17 3 22 17 4 43 18 1 86 18 2 14 18 3 47 18 4 80 19 1 54 19 2 47 19 3 77<br \/>\n19 4 44 20 1 76 20 2 57 20 3 24 20 4 88 21\u00a0 1 56 21\u00a0 2 14 21 3 18 21 4 59<br \/>\n22 1 37 22 2 43 22 3 39 22 4 75 30 1 28 30 2 13 30 3 15 30 4 81 31 1 94<br \/>\n31 2 31 31 3 69 31 4 90 52 1 90 51 2 55 52 3 26 52 4 70 53 1 48 53 2 14<br \/>\n53 3 29 53 4 53 54 1 47 54 2 29 54 3 24 54 4 34<br \/>\n;<br \/>\n\/* Define the axis characteristics *\/<br \/>\naxis1 offset=(0,70) minor=none;\u00a0 axis2 label=(angle=90);<br \/>\npattern1 color = yellow;<\/p>\n<p>\/* The term pattern1 refers to the first item to be graphed. If there were two variables being graphed then we we use pattern1 and pattern3.\u00a0 *\/<br \/>\nproc sort; by xvar;<br \/>\nproc gchart data = behave;<br \/>\nvbar xvar\/ type=MEAN errorbar=BOTH clm=95<br \/>\nsumvar=yvar discrete raxis=axis2 cerror=crimson cr=biv;<br \/>\nformat xvar cndfmt.;<br \/>\n\/* Define the title *\/<br \/>\ntitle1 &#8216;Average Frequency of Behaviour of Interest with 95% CI Standard Error Bars &#8216;;<br \/>\nrun;<\/p>\n<\/div>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/vbarSE.png\" alt=\"\" class=\"aligncenter size-full wp-image-1553\" width=\"1200\" height=\"900\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/vbarSE.png 1200w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/vbarSE-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/vbarSE-1024x768.png 1024w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/vbarSE-768x576.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/vbarSE-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/vbarSE-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/vbarSE-350x263.png 350w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<hr \/>\n<h1>More Simple Barcharts &#8212; Graphing data as a Frequency Distribution Bar Chart<\/h1>\n<p>In the following examples, we use SAS commands to create a three-dimensional vertical bar chart and a horizontal bar chart with a frequency table of the data. In this SAS code, we include formatting commands for the graphical output \u2013 defining the characteristics of each axis \u2013 prior to having the SAS program read the data set.<\/p>\n<h2 id=\"tablepress-8-name\" class=\"tablepress-table-name tablepress-table-name-id-8\">Using GCHART to Produce A Vertical Bar Chart<\/h2>\n<table id=\"tablepress-8\" class=\"tablepress tablepress-id-8\" aria-labelledby=\"tablepress-8-name\" aria-describedby=\"tablepress-8-description\">\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-1\">\n<td class=\"column-1\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/vbar2.png\" alt=\"\" width=\"1000\" height=\"750\" class=\"aligncenter size-full wp-image-1355\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/vbar2.png 1000w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/vbar2-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/vbar2-768x576.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/vbar2-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/vbar2-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/vbar2-350x263.png 350w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/td>\n<\/tr>\n<tr class=\"row-2\">\n<td class=\"column-1\">DATA FAMILIES;<br \/>\nINPUT NKIDS HSEHLD;<br \/>\n\/* DEFINE THE AXIS CHARACTERISTICS *\/ <br \/>\nAXIS1 LABEL=(\"NUMBER OF CHILDREN\") <br \/>\n      VALUE=(JUSTIFY=CENTER); <br \/>\nAXIS2 LABEL=(ANGLE=90 \"FREQUENCY OF HOUSEHOLDS\") \t<br \/>\nORDER=(0 TO 15 BY 3) <br \/>\n      MINOR=(N=3); <br \/>\n      AXIS3 LABEL=(ANGLE=90 \"NUMBER OF CHILDREN\"); <br \/>\n      AXIS4 LABEL=(\"FREQUENCY OF HOUSEHOLDS\") \t;<\/p>\n<p>DATALINES;<br \/>\n00 9<br \/>\n01 7<br \/>\n02 12<br \/>\n03 9<br \/>\n04 5<br \/>\n05 6<br \/>\n06 0<br \/>\n07 2<br \/>\n;<br \/>\nPROC GCHART DATA=FAMILIES;<br \/>\n  VBAR3D NKIDS\/SUMVAR=HSEHLD TYPE=SUM DISCRETE<br \/>\n   COUTLINE=RED WOUTLINE=1 WIDTH=3 MAXIS=AXIS1 RAXIS=AXIS2; <br \/>\nTITLE1 'VERTICAL BAR CHART NUMBER OF CHILDREN IN EACH HOUSEHOLD';<br \/>\nPATTERN1 COLOR = LIGHTBLUE;<br \/>\nRUN;<\/p>\n<p>PROC GCHART DATA=FREQ4_3;<br \/>\n        HBAR NKIDS\/DISCRETE SUMVAR= HSEHLD <br \/>\n        TYPE=SUM DISCRETE COUTLINE=RED WOUTLINE=1 WIDTH=2 <br \/>\n    MAXIS=AXIS3 RAXIS=AXIS4;<br \/>\nTitle1 'HORIZONTAL BAR CHART NUMBER OF CHILDREN IN EACH HOUSEHOLD';<br \/>\nTITLE2 'INCLUDES FREQUENCY VALUES AT END OF EACH BAR';<br \/>\nPATTERN1 COLOR = LIGHTBLUE;<br \/>\nRUN;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span id=\"tablepress-8-description\" class=\"tablepress-table-description tablepress-table-description-id-8\">The essential SAS processing command to produce the vertical bar chart is PROC GCHART. However, the important commands to discriminate the independent and dependent variables are given in the command line:  VBAR3D NKIDS\/SUMVAR=HSEHLD TYPE=SUM DISCRETE.   Here we tell SAS to read the variable NKIDS as the categorical independent variable, while HSEHLD is the dependent variable and is read by the option SUMVAR= HSEHLD. We include the second option TYPE=SUM to indicate that the values entered are actually the sum scores for each category of the independent variable. <\/span><br \/>\n<!-- #tablepress-8 from cache --><\/p>\n<p>Using the same data from the SAS program above and adding two new AXIS labels we can generate a horizontal bar chart with the frequency values included at the end of each horizontal bar.\u00a0 Notice in both the vertical and horizontal bar charts, the length of the bar is proportional to the value of the frequency.<\/p>\n<h2 id=\"tablepress-9-name\" class=\"tablepress-table-name tablepress-table-name-id-9\">Horizontal Bar Chart with Frequency Values Included<\/h2>\n<table id=\"tablepress-9\" class=\"tablepress tablepress-id-9\" aria-labelledby=\"tablepress-9-name\" aria-describedby=\"tablepress-9-description\">\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-1\">\n<td class=\"column-1\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/horzBar1.png\" alt=\"\" width=\"1000\" height=\"417\" class=\"aligncenter size-full wp-image-1360\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/horzBar1.png 1000w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/horzBar1-300x125.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/horzBar1-768x320.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/horzBar1-65x27.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/horzBar1-225x94.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/horzBar1-350x146.png 350w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/td>\n<\/tr>\n<tr class=\"row-2\">\n<td class=\"column-1\">DATA FAMILIES;<br \/>\nINPUT NKIDS HSEHLD @@;<br \/>\n\/* DEFINE THE AXIS CHARACTERISTICS *\/ <\/p>\n<p>AXIS3 LABEL=(ANGLE=90 \"NUMBER OF CHILDREN\"); <br \/>\nAXIS4 LABEL=(\"FREQUENCY OF HOUSEHOLDS\") \t;<\/p>\n<p>DATALINES;<br \/>\n00 9 01 7 02 12 03 9 04 5 05 6 06 0 07 2<br \/>\n;<br \/>\nPROC GCHART DATA=FAMILIES;<br \/>\n        HBAR NKIDS\/DISCRETE SUMVAR= HSEHLD <br \/>\n        TYPE=SUM DISCRETE COUTLINE=RED WOUTLINE=1 WIDTH=2 <br \/>\n    MAXIS=AXIS3 RAXIS=AXIS4;<br \/>\nTitle1 'HORIZONTAL BAR CHART NUMBER OF CHILDREN IN EACH HOUSEHOLD';<br \/>\nTITLE2 'INCLUDES FREQUENCY VALUES AT END OF EACH BAR';<br \/>\nPATTERN1 COLOR = LIGHTBLUE;<br \/>\nRUN;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span id=\"tablepress-9-description\" class=\"tablepress-table-description tablepress-table-description-id-9\">Notice in the input statement, the variables are defined and two @ symbols are used to hold the cursor at the line until all values are entered in sequence. <br \/>\nINPUT NKIDS HSEHLD @@;<br \/>\nThis style for data entry economizes space in programming.<\/span><br \/>\n<!-- #tablepress-9 from cache --><\/p>\n<p>In the following example, we return to the HDX dataset to observe the total number of cases of the Ebola virus across selected countries. These data are based on the actual reports of cases and deaths related to the 2014 West Africa Ebola Outbreak.<\/p>\n<p>Sample Data Of Total Cases Of Ebola Virus Across Selected Countries<\/p>\n<table id=\"tablepress-10\" class=\"tablepress tablepress-id-10\">\n<thead>\n<tr class=\"row-1\">\n<th class=\"column-1\">Country\t<\/th>\n<th class=\"column-2\">Case definition<\/th>\n<th class=\"column-3\">Total cases<\/th>\n<th class=\"column-4\">\tTotal deaths<\/th>\n<th class=\"column-5\">Country report date<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n<td class=\"column-1\">Guinea\t<\/td>\n<td class=\"column-2\">Confirmed<\/td>\n<td class=\"column-3\">2384<\/td>\n<td class=\"column-4\">1422<\/td>\n<td class=\"column-5\">2014-12-27<\/td>\n<\/tr>\n<tr class=\"row-3\">\n<td class=\"column-1\"><\/td>\n<td class=\"column-2\">Probable\t<\/td>\n<td class=\"column-3\">275<\/td>\n<td class=\"column-4\">275<\/td>\n<td class=\"column-5\"><\/td>\n<\/tr>\n<tr class=\"row-4\">\n<td class=\"column-1\"><\/td>\n<td class=\"column-2\">Suspected<\/td>\n<td class=\"column-3\">36<\/td>\n<td class=\"column-4\">0<\/td>\n<td class=\"column-5\"><\/td>\n<\/tr>\n<tr class=\"row-5\">\n<td class=\"column-1\"><\/td>\n<td class=\"column-2\">All<\/td>\n<td class=\"column-3\">2695<\/td>\n<td class=\"column-4\">1697<\/td>\n<td class=\"column-5\"><\/td>\n<\/tr>\n<tr class=\"row-6\">\n<td class=\"column-1\">Liberia<\/td>\n<td class=\"column-2\">Confirmed<\/td>\n<td class=\"column-3\">3108<\/td>\n<td class=\"column-4\">..<\/td>\n<td class=\"column-5\">2014-12-24<\/td>\n<\/tr>\n<tr class=\"row-7\">\n<td class=\"column-1\"><\/td>\n<td class=\"column-2\">Probable\t<\/td>\n<td class=\"column-3\">1773<\/td>\n<td class=\"column-4\">..<\/td>\n<td class=\"column-5\"><\/td>\n<\/tr>\n<tr class=\"row-8\">\n<td class=\"column-1\"><\/td>\n<td class=\"column-2\">Suspected<\/td>\n<td class=\"column-3\">3096<\/td>\n<td class=\"column-4\">..<\/td>\n<td class=\"column-5\"><\/td>\n<\/tr>\n<tr class=\"row-9\">\n<td class=\"column-1\"><\/td>\n<td class=\"column-2\">All<\/td>\n<td class=\"column-3\">7977<\/td>\n<td class=\"column-4\">3413<\/td>\n<td class=\"column-5\"><\/td>\n<\/tr>\n<tr class=\"row-10\">\n<td class=\"column-1\">Sierra Leone<\/td>\n<td class=\"column-2\">Confirmed<\/td>\n<td class=\"column-3\">7326<\/td>\n<td class=\"column-4\">2366<\/td>\n<td class=\"column-5\">2014-12-27<\/td>\n<\/tr>\n<tr class=\"row-11\">\n<td class=\"column-1\"><\/td>\n<td class=\"column-2\">Probable\t<\/td>\n<td class=\"column-3\">287<\/td>\n<td class=\"column-4\">208<\/td>\n<td class=\"column-5\"><\/td>\n<\/tr>\n<tr class=\"row-12\">\n<td class=\"column-1\"><\/td>\n<td class=\"column-2\">Suspected<\/td>\n<td class=\"column-3\">1796<\/td>\n<td class=\"column-4\">158<\/td>\n<td class=\"column-5\"><\/td>\n<\/tr>\n<tr class=\"row-13\">\n<td class=\"column-1\"><\/td>\n<td class=\"column-2\">All\t<\/td>\n<td class=\"column-3\">9409<\/td>\n<td class=\"column-4\">2732<\/td>\n<td class=\"column-5\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!-- #tablepress-10 from cache --><\/p>\n<p>The SAS program and corresponding output from the analysis is presented below. Notice that only the data for <em>confirmed, probable <\/em>and<em> suspected<\/em> cases are being used in the dataset. These data represent the summary of counts whereby the units of measurement are the total number of cases and the total number of deaths.<\/p>\n<div class=\"textbox textbox--examples\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">SAS Program to Create a Frequency Distribution for Ebola Outbreak<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<div>OPTIONS PAGESIZE=60 LINESIZE=80;<br \/>\nDATA GRAPH1;<br \/>\nINPUT COUNTRY $ 1-12 DEF $ 15-23 CASES 26-29;<br \/>\nLABEL DEF=&#8217;DEFINITION OF CASES&#8217;;<br \/>\nDATALINES;<br \/>\nGUINEA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 CONFIRMED\u00a0 2384<br \/>\nGUINEA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 PROBABLE\u00a0\u00a0\u00a0 275<br \/>\nGUINEA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 SUSPECTED\u00a0\u00a0\u00a0 36<br \/>\nLIBERIA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0CONFIRMED\u00a0 3108<br \/>\nLIBERIA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0PROBABLE\u00a0\u00a0 1773<br \/>\nLIBERIA\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0SUSPECTED\u00a0 3096<br \/>\nSIERRA LEONE\u00a0 CONFIRMED\u00a0 7326<br \/>\nSIERRA LEONE\u00a0 PROBABLE\u00a0\u00a0\u00a0 287<br \/>\nSIERRA LEONE\u00a0 SUSPECTED\u00a0 1796<br \/>\n;<br \/>\nPROC SORT; BY COUNTRY;<br \/>\nPROC FREQ; TABLES COUNTRY\/OUT=CASEPCT; WEIGHT CASES;<br \/>\nRUN;<\/div>\n<\/div>\n<\/div>\n<div>\n<p><span>The output from the PROC FREQ procedure is shown here.<\/span><\/p>\n<\/div>\n<div style=\"margin: auto;\">\n<table>\n<thead>\n<tr>\n<td><strong>COUNTRY<\/strong><\/td>\n<td><strong>Frequency<\/strong><\/td>\n<td><strong>Percent<\/strong><\/td>\n<td><strong>Cumulative<br \/>\nFrequency<\/strong><\/td>\n<td><strong>Cumulative<br \/>\nPercent<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>GUINEA<\/strong><\/td>\n<td>2695<\/td>\n<td>13.42<\/td>\n<td>2695<\/td>\n<td>13.42<\/td>\n<\/tr>\n<tr>\n<td><strong>LIBERIA<\/strong><\/td>\n<td>7977<\/td>\n<td>39.72<\/td>\n<td>10672<\/td>\n<td>53.14<\/td>\n<\/tr>\n<tr>\n<td><strong>SIERRA LEONE<\/strong><\/td>\n<td>9409<\/td>\n<td>46.86<\/td>\n<td>20081<\/td>\n<td>100.00<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>In the code above we produce an output file that represents the percent value of the cases based on the sum of cases in each country. For example, all of the cases for GUINEA regardless of whether the cases were\u00a0 PROBABLE, SUSPECTED, or CONFIRMED, equal 2695 which represents 13.42 percent of the total number of cases. The total number of cases across all countries is reported in the last row of the <strong>Cumulative Frequency<\/strong> column and is 20081.<\/p>\n<p>Below, the output data file (DATA=CASEPCT) is used in a PROC GCHART procedure to produce a horizontal bar chart using the SUMVAR option with the data from the PERCENT column.<\/p>\n<table style=\"background-color: #ffb833;\">\n<tbody>\n<tr>\n<td><span>PROC FORMAT; PICTURE PCTFMT (ROUND) 0-HIGH=&#8217;000%&#8217;;<\/span><\/p>\n<p><span>PROC GCHART DATA=CASEPCT; HBAR COUNTRY\/ SUMVAR = PERCENT;<\/span><\/p>\n<p><span>FORMAT PERCENT PCTFMT.;<\/span><\/p>\n<p><span>RUN;<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/casepct.png\" alt=\"\" class=\"aligncenter wp-image-1378\" width=\"825\" height=\"264\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/casepct.png 1000w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/casepct-300x96.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/casepct-768x246.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/casepct-65x21.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/casepct-225x72.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/casepct-350x112.png 350w\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" \/><\/p>\n<hr \/>\n<h1>Creating a Line Graph to Summarize Data<\/h1>\n<p>In this program, we will use the SAS PROC GPLOT functions to observe \u201cat a glance\u201d a comparison of the unadjusted differences in life expectancy at birth for males versus females in Canada, based on data reported since 1994. The data used in this example range from an initial value of 74.9 years for males and 80.9 years for females in 1994, to life expectancy scores of 79.8 years for males and 83.9 years for females, in 2015. Here we see that at each year of reporting life expectancy estimates, the females are predicted to live longer than males, on average.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/lifeExp.png\" alt=\"\" class=\"aligncenter wp-image-453 size-full\" width=\"640\" height=\"480\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/lifeExp.png 640w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/lifeExp-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/lifeExp-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/lifeExp-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/lifeExp-350x263.png 350w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<div class=\"textbox textbox--exercises\">\n<header class=\"textbox__header\">\n<h4><span style=\"color: #ffffff\">SAS SGPLOT to Produce Comparison of Life Expectancy Scores<\/span><\/h4>\n<\/header>\n<div class=\"textbox__content\">\n<p>PROC FORMAT;<br \/>\nVALUE $SXFMT &#8216;F&#8217;=&#8217;FEMALE&#8217; &#8216;M&#8217;=&#8217;MALE&#8217;;<br \/>\nVALUE YRFMT 1=&#8217;1994\/1995&#8242; 2=&#8217;1998\/1999&#8242; 3=&#8217;2001&#8242; 4=&#8217;2005&#8242; 5=&#8217;2009\/2010&#8242; 6=&#8217;2015&#8242;;<br \/>\nVALUE SRCFMT 1=&#8217;UNADJUSTED LIFE EXPECTANCY&#8217; 2=&#8217;HEALTH ADJUSTED LIFE EXPECTANCY&#8217;;<\/p>\n<p>LABEL SCORE= &#8216;LIFE EXPECTANCY AT BIRTH&#8217;;<br \/>\nLABEL YEAR= &#8216;YEAR OF REPORTING&#8217;;<\/p>\n<p>DATA CH7FIG1;<br \/>\nINPUT ID SEX $ YEAR SOURCE SCORE @@;<br \/>\nDATALINES;<br \/>\n01 M 1 1 74.9 02 M 2 1 76.0 03 M 3 1 76.9 04 M 4 1 77.9 05 M 5 1 79.1 \u00a0M 06 6 1 79.8 07 M 1 2 65.0 08 M 2 2 67.4 09 M 3 2 67.3 10 M 4 2 68.1<br \/>\n11 M 5 2 69.3 12 M 6 2 69.0 13 F 1 1 80.9 14 F 2 1 81.4 15 F 3 1 81.9<br \/>\n16 F 4 1 82.6 17 F 5 1 83.5 18 F 6 1 83.9 19 F 1 2 67.8 20 F 2 2 70.1<br \/>\n21 F 3 2 69.8 22 F 4 2 70.6 23 F 5 2 71.3 24 F 6 2 70.5<br \/>\n;<br \/>\nTITLE2 &#8216;COMPARISON OF LIFE EXPECTANCY AT BIRTH (FEMALES VS MALES)&#8217;;<\/p>\n<p>FOOTNOTE1 J=L &#8221; SOURCE: STATS CANADA CATALOGUE NO. 82-003-X ISSN 1209-1367&#8243;;<\/p>\n<p>AXIS1 ORDER=(1990 TO 2015 BY 5) OFFSET=(2,2) LABEL=NONE<br \/>\nMAJOR=(HEIGHT=2) MINOR=(HEIGHT=1) ;<\/p>\n<p>AXIS2 ORDER=(50 TO 100 BY 5) OFFSET=(0,0) LABEL=NONE<br \/>\nMAJOR=(HEIGHT=2) MINOR=(HEIGHT=1);<\/p>\n<p>LEGEND1 LABEL=NONE POSITION=(TOP CENTER INSIDE)<br \/>\nMODE=SHARE;<\/p>\n<p>RUN;<br \/>\nPROC SORT; BY SEX;<br \/>\nPROC SGPLOT;<\/p>\n<p>SERIES X = YEAR Y = SCORE\/GROUP=SEX lineattrs=(thickness=4);<\/p>\n<p>XAXIS TYPE = DISCRETE;<br \/>\nstyleattrs datacontrastcolors=(RED NAVY)<br \/>\ndatalinepatterns=(SOLID);<\/p>\n<p>WHERE SOURCE=1 ;<\/p>\n<p>FORMAT YEAR YRFMT. SOURCE SRCFMT. ;<\/p>\n<p>RUN;<\/p>\n<\/div>\n<\/div>\n<h2>Adding the WHERE command to restrict output<\/h2>\n<p>In the following line graph, we observe the Health Adjusted Life Expectancy, also referred to as HALE data comparison between males and females changes the contours of the lines for the predicted values of the female and male response data. Again these data range from first reports in 1994 taken from the National Population Health Survey and the Canadian Census in 1993 to 1995 to data from the Canadian Community Health Survey, as well as the NPHS and Census up to and including 2015 (Bushnik, Tjepkema, Martel, 2018)<a href=\"#_ftn1\">[1]<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/HALE.png\" alt=\"\" class=\"aligncenter wp-image-455 size-full\" width=\"640\" height=\"480\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/HALE.png 640w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/HALE-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/HALE-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/HALE-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/HALE-350x263.png 350w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>The SAS program to produce the line graph above includes the <strong>PROC SGPLOT<\/strong> statement and the command\u00a0 <strong>WHERE SOURCE=1<\/strong>;\u00a0 This restricts the processing of the graphing procedure to only select the unadjusted life expectancy values from the dependent variable <strong>SCORE<\/strong>. When we change the command <strong>WHERE SOURCE=2<\/strong>; then we change the output to only consider health adjusted values from the dependent variable SCORE.<\/p>\n<p>Here we use the PROC FORMAT feature to ensure that the data are converted to explanatory labels and these labels are included in the graphs.<\/p>\n<div class=\"textbox textbox--exercises\">\n<header class=\"textbox__header\">\n<h4><span style=\"color: #ffffff\">SAS SGPLOT to produce Health Adjusted Comparison of Life Expectancy Scores<\/span><\/h4>\n<\/header>\n<div class=\"textbox__content\">\n<p>This program is incorporating the WHERE command to restrict output to a subgroup.<\/p>\n<p>PROC SORT; BY SEX;<br \/>\nPROC SGPLOT; SERIES X = YEAR Y = SCORE\/GROUP=SEX<br \/>\nlineattrs=(thickness=4);XAXIS TYPE = DISCRETE;<br \/>\nstyleattrs datacontrastcolors=(RED BLUE)<br \/>\ndatalinepatterns=(SOLID);<br \/>\nWHERE SOURCE=2 ;<\/p>\n<p>FORMAT YEAR YRFMT. SOURCE SRCFMT. ;<\/p>\n<p>RUN;<\/p>\n<\/div>\n<\/div>\n<div>\n<div>\n<p><a href=\"#_ftnref1\">[1]<\/a>Bushnik, T., Tjepkema, M., &amp; Martel, L., Health-adjusted life Expectancy in Canada, Statistics Canada. Catalogue no. 82-003-X ISSN 1209-1367<\/p>\n<\/div>\n<p>Let&#8217;s add one more line graph here to show the comparison of the number of reported cases for COVID-19 for the months of August and September in Canada. Note, the PROC SORT command is extremely important here.<\/p>\n<p>The SAS program and corresponding output are shown below.<\/p>\n<div class=\"textbox\">\n<p>PROC FORMAT;<br \/>\nVALUE $MNFMT 08=\u2019August\u2019 09=\u2019September\u2019;<br \/>\nDATA A3Q1C;<br \/>\nINPUT MONTH DAY CASES @@;<br \/>\nTITLE2 \u2018NUMBER OF CORONAVIRUS CASES IN THE MONTHS OF AUGUST AND SEPTEMBER 2020\u2019;<br \/>\nLABEL CASES= \u2018NUMBER OF CASES\u2019;<br \/>\nLABEL DAY= \u2018DAY OF REPORTING\u2019;<br \/>\nDATALINES;<br \/>\n08 01 319 08 08 326 08 15 342 08 22 389 08 29 425<br \/>\n08 02 322 08 09 314 08 16 364 08 23 379 08 30 508<br \/>\n08 03 414 08 10 425 08 17 505 08 24 548 08 31 614<br \/>\n08 04 414 08 11 425 08 18 401 08 25 571<br \/>\n08 05 368 08 12 378 08 19 409 08 26 539<br \/>\n08 06 336 08 13 363 08 20 414 08 27 444<br \/>\n08 07 363 08 14 340 08 21 401 08 28 540<br \/>\n09 01 705 09 09 922 09 15 1283 09 22 1792 09 29 2157<br \/>\n09 02 681 09 09 938 09 16 1294 09 23 1812 09 30 2160<br \/>\n09 03 599 09 10 901 09 17 1234 09 24 1843<br \/>\n09 04 687 09 11 898 09 18 1336 09 25 2010<br \/>\n09 05 641 09 12 955 09 19 1236 09 26 1753<br \/>\n09 06 656 09 13 923 09 20 1265 09 27 1873<br \/>\n09 07 767 09 14 1210 09 21 1746 09 28 2350<br \/>\n;<\/p>\n<p>TITLE2 \u2018COMPARISON OF CASES BY MONTHS (AUGUST AND SEPTEMBER)\u2019;<br \/>\nFOOTNOTE1 J=L &#8220;see source code for data reference &#8212; HEALTH INFOBASE CANADA&#8221;;<br \/>\n\/*<br \/>\n* https:\/\/health-infobase.canada.ca\/covid-19\/epidemiological-summary-covid-19-cases.html<br \/>\n*\/<br \/>\nAXIS1 ORDER=(1 TO 31 BY 1) OFFSET=(22) LABEL=NONE MAJOR=(HEIGHT=2) MINOR=(HEIGHT=1) ;<\/p>\n<p>AXIS2 ORDER=(100 TO 2500 BY 100) OFFSET=(00) LABEL=NONE MAJOR=(HEIGHT=2) MINOR=(HEIGHT=1);<\/p>\n<p>LEGEND1 LABEL=NONE POSITION=(TOP CENTER INSIDE) MODE=SHARE;<\/p>\n<p>RUN;<br \/>\nPROC SORT; BY DAY;<br \/>\nPROC SGPLOT;<br \/>\nSERIES X = DAY Y = CASES \/ GROUP=MONTH lineattrs=(thickness=4);<br \/>\nFORMAT MONTH MNFMT. ;<br \/>\nXAXIS TYPE = DISCRETE;<br \/>\nstyleattrs datacontrastcolors=(RED NAVY)<br \/>\ndatalinepatterns=(SOLID);<\/p>\n<p>RUN;<\/p>\n<\/div>\n<div class=\"textbox textbox--examples\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Plotting Coronq Virus cases: Data for Canada Months of August and September<\/p>\n<\/header>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/c19casesbymonth.png\" alt=\"\" class=\"aligncenter size-full wp-image-2106\" width=\"640\" height=\"480\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/c19casesbymonth.png 640w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/c19casesbymonth-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/c19casesbymonth-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/c19casesbymonth-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/c19casesbymonth-350x263.png 350w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<div>\n<hr \/>\n<h1>Creating a Pie Chart to Represent Summary Data<\/h1>\n<p>In the following example, we present a pie chart of the data from The Humanitarian Data Exchange (url: https:\/\/data.hdx.rwlabs.org\/) a project from the United Nations Office for the Coordination of Humanitarian Aid (url: http:\/\/www.unocha.org\/).<\/p>\n<p>On January 15th, 2016 the World Health Organization declared the country of Sierra Leone as Ebola-free. However, by that time Sierra Leone had recorded approximately 4000 deaths from the Ebola Virus. In this second example, we will generate a pie chart. The data are based on confirmed cases of Ebola for Sierra Leone by region from 2014 to December 28, 2014. The data represent the cumulative deaths since the recognized beginning of the Ebola virus outbreak in April 2014.<\/p>\n<table id=\"tablepress-6\" class=\"tablepress tablepress-id-6\" aria-describedby=\"tablepress-6-description\">\n<thead>\n<tr class=\"row-1\">\n<th class=\"column-1\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/pie1.png\" alt=\"\" width=\"647\" height=\"597\" class=\"aligncenter size-full wp-image-1308\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/pie1.png 647w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/pie1-300x277.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/pie1-65x60.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/pie1-225x208.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/07\/pie1-350x323.png 350w\" sizes=\"auto, (max-width: 647px) 100vw, 647px\" \/><\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n<td class=\"column-1\">\/* ******************************************************************<br \/>\n* SAS CODE TO PRODUCE PIE CHART FOR EBOLA  RELATED <br \/>\n* DEATHS IN CITIES OF SIERRA LEONE<br \/>\n* BE SURE TO CHECK COLUMN ALIGNMENT <br \/>\n******************************************************************* *\/.<\/p>\n<p>OPTIONS PAGESIZE=55 LINESIZE=120 CENTER DATE;<br \/>\nLIBNAME SAMPLE '\/HOME\/WMONTELPARE\/MN636_EXAMPLES\/';<br \/>\nDATA SAMPLE.PIE1;<br \/>\n   INPUT CITY $ 1-19 @23 CONFIRM D21DAYS 29-31;<br \/>\nDATALINES;<\/td>\n<\/tr>\n<tr class=\"row-3\">\n<td class=\"column-1\">WESTERN AREA URBAN     1803   400 <br \/>\nWESTERN AREA RURAL         997    112<br \/>\nKAMBIA                                    108     22<br \/>\nPORT LOKO                           1175.   219<br \/>\nTONKOLILI                              426      41<br \/>\nKONO                                      176      70<br \/>\nKAILAHUN                              565       3<br \/>\nKENEMA                                 496       2<br \/>\nPUJEHUN                                 31        0<br \/>\nKOINADUGU                            97      11<br \/>\nBO                                           305     36<br \/>\nBONTHE                                     5        1<br \/>\nBOMBALI                                961      81<br \/>\nMOYAMBA                              181       11<\/td>\n<\/tr>\n<tr class=\"row-4\">\n<td class=\"column-1\">;<br \/>\nRUN;<\/p>\n<p>TITLE1 'PIE CHART OF EBOLA DEATHS BY CITY IN SIERRA LEONE';<br \/>\nPROC GCHART DATA=SAMPLE.PIE1;<br \/>\n PIE CITY \/ SUMVAR=CONFIRM NOHEADING;<br \/>\nRUN;\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span id=\"tablepress-6-description\" class=\"tablepress-table-description tablepress-table-description-id-6\">The data for this example are taken from the HDX: The Humanitarian Data Exchange to represent deaths from the Ebola outbreak in Sierra Leone in 2014. <\/span><br \/>\n<!-- #tablepress-6 from cache --><\/p>\n<hr \/>\n<h1>Producing Bubble Plots<\/h1>\n<p>SOURCE: HDX: The Humanitarian Data Exchange <a href=\"#_ftn1\">[1]<\/a><\/p>\n<p>In the following example data set the cumulative number of health-care workers deaths by Ebola Disease Virus are reported. These data were extracted from WHO: Ebola Response Roadmap Situation Reports, the data are based on extraction from data reported on 24 December 2014. Here we can plot the total deaths from these data by country, and within each country by month and use appropriate axes titles and legend. The data are presented first in the table below and then as two separate bubble plots. The size of the bubbles represents the frequency value for the total number of deaths reported.<\/p>\n<h2 id=\"tablepress-11-name\" class=\"tablepress-table-name tablepress-table-name-id-11\">Number Of Health-Care Workers Deaths By Ebola Disease Virus (Sept 2014 - Dec 2014)<\/h2>\n<table id=\"tablepress-11\" class=\"tablepress tablepress-id-11\" aria-labelledby=\"tablepress-11-name\" aria-describedby=\"tablepress-11-description\">\n<thead>\n<tr class=\"row-1\">\n<th class=\"column-1\">Country<\/th>\n<th class=\"column-2\">Total deaths<\/th>\n<th class=\"column-3\">Month<\/th>\n<th class=\"column-4\">Country<\/th>\n<th class=\"column-5\">Total deaths<\/th>\n<th class=\"column-6\">Month<\/th>\n<th class=\"column-7\">Country<\/th>\n<th class=\"column-8\">Total deaths<\/th>\n<th class=\"column-9\">Month<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n<td class=\"column-1\">Guinea<\/td>\n<td class=\"column-2\">27<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Sierra Leone<\/td>\n<td class=\"column-5\">81<\/td>\n<td class=\"column-6\">Sept<\/td>\n<td class=\"column-7\">Liberia<\/td>\n<td class=\"column-8\">103<\/td>\n<td class=\"column-9\">Oct<\/td>\n<\/tr>\n<tr class=\"row-3\">\n<td class=\"column-1\">Liberia<\/td>\n<td class=\"column-2\">81<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Guinea<\/td>\n<td class=\"column-5\">35<\/td>\n<td class=\"column-6\">Sept<\/td>\n<td class=\"column-7\">Nigeria<\/td>\n<td class=\"column-8\">5<\/td>\n<td class=\"column-9\">Oct<\/td>\n<\/tr>\n<tr class=\"row-4\">\n<td class=\"column-1\">Sierra Leone<\/td>\n<td class=\"column-2\">31<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Liberia<\/td>\n<td class=\"column-5\">95<\/td>\n<td class=\"column-6\">Sept<\/td>\n<td class=\"column-7\">Sierra Leone<\/td>\n<td class=\"column-8\">95<\/td>\n<td class=\"column-9\">Oct<\/td>\n<\/tr>\n<tr class=\"row-5\">\n<td class=\"column-1\">Guinea<\/td>\n<td class=\"column-2\">30<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Nigeria<\/td>\n<td class=\"column-5\">5<\/td>\n<td class=\"column-6\">Sept<\/td>\n<td class=\"column-7\">Guinea<\/td>\n<td class=\"column-8\">43<\/td>\n<td class=\"column-9\">Oct<\/td>\n<\/tr>\n<tr class=\"row-6\">\n<td class=\"column-1\">Liberia<\/td>\n<td class=\"column-2\">85<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Sierra Leone<\/td>\n<td class=\"column-5\">81<\/td>\n<td class=\"column-6\">Sept<\/td>\n<td class=\"column-7\">Liberia<\/td>\n<td class=\"column-8\">123<\/td>\n<td class=\"column-9\">Oct<\/td>\n<\/tr>\n<tr class=\"row-7\">\n<td class=\"column-1\">Nigeria<\/td>\n<td class=\"column-2\">5<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Guinea<\/td>\n<td class=\"column-5\">40<\/td>\n<td class=\"column-6\">Oct<\/td>\n<td class=\"column-7\">Nigeria<\/td>\n<td class=\"column-8\">5<\/td>\n<td class=\"column-9\">Oct<\/td>\n<\/tr>\n<tr class=\"row-8\">\n<td class=\"column-1\">Sierra Leone<\/td>\n<td class=\"column-2\">31<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Liberia<\/td>\n<td class=\"column-5\">96<\/td>\n<td class=\"column-6\">Oct<\/td>\n<td class=\"column-7\">Sierra Leone<\/td>\n<td class=\"column-8\">101<\/td>\n<td class=\"column-9\">Oct<\/td>\n<\/tr>\n<tr class=\"row-9\">\n<td class=\"column-1\">Guinea<\/td>\n<td class=\"column-2\">35<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Nigeria<\/td>\n<td class=\"column-5\">5<\/td>\n<td class=\"column-6\">Oct<\/td>\n<td class=\"column-7\">Guinea<\/td>\n<td class=\"column-8\">46<\/td>\n<td class=\"column-9\">Nov<\/td>\n<\/tr>\n<tr class=\"row-10\">\n<td class=\"column-1\">Liberia<\/td>\n<td class=\"column-2\">87<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Sierra Leone<\/td>\n<td class=\"column-5\">95<\/td>\n<td class=\"column-6\">Oct<\/td>\n<td class=\"column-7\">Liberia<\/td>\n<td class=\"column-8\">157<\/td>\n<td class=\"column-9\">Nov<\/td>\n<\/tr>\n<tr class=\"row-11\">\n<td class=\"column-1\">Nigeria<\/td>\n<td class=\"column-2\">5<\/td>\n<td class=\"column-3\">Sept<\/td>\n<td class=\"column-4\">Guinea<\/td>\n<td class=\"column-5\">41<\/td>\n<td class=\"column-6\">Oct<\/td>\n<td class=\"column-7\">Nigeria<\/td>\n<td class=\"column-8\">5<\/td>\n<td class=\"column-9\">Nov<\/td>\n<\/tr>\n<tr class=\"row-12\">\n<td class=\"column-1\">Guinea<\/td>\n<td class=\"column-2\">56<\/td>\n<td class=\"column-3\">Nov<\/td>\n<td class=\"column-4\">Mali<\/td>\n<td class=\"column-5\">2<\/td>\n<td class=\"column-6\">Nov<\/td>\n<td class=\"column-7\">Sierra Leone<\/td>\n<td class=\"column-8\">102<\/td>\n<td class=\"column-9\">Nov<\/td>\n<\/tr>\n<tr class=\"row-13\">\n<td class=\"column-1\">Liberia<\/td>\n<td class=\"column-2\">172<\/td>\n<td class=\"column-3\">Nov<\/td>\n<td class=\"column-4\">Guinea<\/td>\n<td class=\"column-5\">59<\/td>\n<td class=\"column-6\">Nov<\/td>\n<td class=\"column-7\">Guinea<\/td>\n<td class=\"column-8\">55<\/td>\n<td class=\"column-9\">Nov<\/td>\n<\/tr>\n<tr class=\"row-14\">\n<td class=\"column-1\">Sierra Leone<\/td>\n<td class=\"column-2\">105<\/td>\n<td class=\"column-3\">Nov<\/td>\n<td class=\"column-4\">Liberia<\/td>\n<td class=\"column-5\">174<\/td>\n<td class=\"column-6\">Nov<\/td>\n<td class=\"column-7\">Liberia<\/td>\n<td class=\"column-8\">170<\/td>\n<td class=\"column-9\">Nov<\/td>\n<\/tr>\n<tr class=\"row-15\">\n<td class=\"column-1\">Nigeria<\/td>\n<td class=\"column-2\">5<\/td>\n<td class=\"column-3\">Nov<\/td>\n<td class=\"column-4\">Sierra Leone<\/td>\n<td class=\"column-5\">106<\/td>\n<td class=\"column-6\">Nov<\/td>\n<td class=\"column-7\">Nigeria<\/td>\n<td class=\"column-8\">5<\/td>\n<td class=\"column-9\">Nov<\/td>\n<\/tr>\n<tr class=\"row-16\">\n<td class=\"column-1\">Guinea<\/td>\n<td class=\"column-2\">51<\/td>\n<td class=\"column-3\">Nov<\/td>\n<td class=\"column-4\">Nigeria<\/td>\n<td class=\"column-5\">5<\/td>\n<td class=\"column-6\">Nov<\/td>\n<td class=\"column-7\">Sierra Leone<\/td>\n<td class=\"column-8\">104<\/td>\n<td class=\"column-9\">Nov<\/td>\n<\/tr>\n<tr class=\"row-17\">\n<td class=\"column-1\">Liberia<\/td>\n<td class=\"column-2\">162<\/td>\n<td class=\"column-3\">Nov<\/td>\n<td class=\"column-4\">Guinea<\/td>\n<td class=\"column-5\">62<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Guinea<\/td>\n<td class=\"column-8\">62<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-18\">\n<td class=\"column-1\">Nigeria<\/td>\n<td class=\"column-2\">5<\/td>\n<td class=\"column-3\">Nov<\/td>\n<td class=\"column-4\">Liberia<\/td>\n<td class=\"column-5\">174<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Liberia<\/td>\n<td class=\"column-8\">174<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-19\">\n<td class=\"column-1\">Sierra Leone<\/td>\n<td class=\"column-2\">102<\/td>\n<td class=\"column-3\">Nov<\/td>\n<td class=\"column-4\">Sierra Leone<\/td>\n<td class=\"column-5\">106<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Sierra Leone<\/td>\n<td class=\"column-8\">106<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-20\">\n<td class=\"column-1\">Nigeria<\/td>\n<td class=\"column-2\">5<\/td>\n<td class=\"column-3\">Dec<\/td>\n<td class=\"column-4\">Liberia<\/td>\n<td class=\"column-5\">177<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Nigeria<\/td>\n<td class=\"column-8\">5<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-21\">\n<td class=\"column-1\">Mali<\/td>\n<td class=\"column-2\">2<\/td>\n<td class=\"column-3\">Dec<\/td>\n<td class=\"column-4\">Sierra Leone<\/td>\n<td class=\"column-5\">110<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Mali<\/td>\n<td class=\"column-8\">2<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-22\">\n<td class=\"column-1\">Guinea<\/td>\n<td class=\"column-2\">72<\/td>\n<td class=\"column-3\">Dec<\/td>\n<td class=\"column-4\">Nigeria<\/td>\n<td class=\"column-5\">5<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Guinea<\/td>\n<td class=\"column-8\">72<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-23\">\n<td class=\"column-1\">Liberia<\/td>\n<td class=\"column-2\">177<\/td>\n<td class=\"column-3\">Dec<\/td>\n<td class=\"column-4\">Mali<\/td>\n<td class=\"column-5\">2<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Liberia<\/td>\n<td class=\"column-8\">177<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-24\">\n<td class=\"column-1\">Sierra Leone<\/td>\n<td class=\"column-2\">109<\/td>\n<td class=\"column-3\">Dec<\/td>\n<td class=\"column-4\">Sierra Leone<\/td>\n<td class=\"column-5\">110<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Sierra Leone<\/td>\n<td class=\"column-8\">109<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-25\">\n<td class=\"column-1\">Nigeria<\/td>\n<td class=\"column-2\">5<\/td>\n<td class=\"column-3\">Dec<\/td>\n<td class=\"column-4\">Nigeria<\/td>\n<td class=\"column-5\">5<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Nigeria<\/td>\n<td class=\"column-8\">5<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-26\">\n<td class=\"column-1\">Mali<\/td>\n<td class=\"column-2\">2<\/td>\n<td class=\"column-3\">Dec<\/td>\n<td class=\"column-4\">Liberia<\/td>\n<td class=\"column-5\">177<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Mali<\/td>\n<td class=\"column-8\">2<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<tr class=\"row-27\">\n<td class=\"column-1\">Guinea<\/td>\n<td class=\"column-2\">72<\/td>\n<td class=\"column-3\">Dec<\/td>\n<td class=\"column-4\">Mali<\/td>\n<td class=\"column-5\">2<\/td>\n<td class=\"column-6\">Dec<\/td>\n<td class=\"column-7\">Guinea<\/td>\n<td class=\"column-8\">72<\/td>\n<td class=\"column-9\">Dec<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span id=\"tablepress-11-description\" class=\"tablepress-table-description tablepress-table-description-id-11\">Data Source: (url: https:\/\/data.hdx.rwlabs.org\/) a project from the United Nations Office for the Coordination of Humanitarian Aid (url: http:\/\/www.unocha.org\/)<\/span><br \/>\n<!-- #tablepress-11 from cache --><\/p>\n<p>The SAS program to analyze these data is presented below. Notice that the dataset presented above used three columns: Country, Total Deaths, and Months, which are repeated three times, using the following input statement.\u00a0 The double trailing @@ symbols hold the pointer at the end of the line to ensure that the data read as three variables repeated three times.<\/p>\n<p>Sample Code:<\/p>\n<div>\n<p>\u00a0<span style=\"color: #0000ff\">\u00a0 INPUT COUNTRY $ TOTDTH MONTH $ @@;<\/span><\/p>\n<\/div>\n<p>In this way, the SAS program reads the data and produces the output for the entire dataset. Notice that we precede the input statement by declaring the length of the contents of the variable <span style=\"color: #0000ff\">COUNTRY<\/span> to be <strong><span style=\"text-decoration: underline\">more than 12 characters<\/span><\/strong> in length.<\/p>\n<div><\/div>\n<div>\n<div class=\"textbox textbox--examples\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">SAS code to Produce Bubble Chart<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<div>OPTIONS PAGESIZE=55 LINESIZE=120 CENTER DATE;<br \/>\nDATA GRAPH2;<br \/>\nLENGTH COUNTRY $12.;<br \/>\nINPUT COUNTRY $ TOTDTH MONTH $ @@;<br \/>\nLABEL TOTDTH =&#8217;NUMBER OF DEATHS&#8217;;DATALINES;<br \/>\n&lt;<strong>DATA GOES HERE<\/strong>&gt;<\/div>\n<p>Sample of the raw data:<\/p>\n<div>Guinea 27 Sept\u00a0 Sierra_Leone 81 Sept Liberia\u00a0 103 Oct\u00a0 Liberia 81 Sept\u00a0 Guinea\u00a0 35 Sept Nigeria 5 Oct<br \/>\nSierra_Leone 31 Sept\u00a0 Liberia 95 Sept Sierra_Leone\u00a0 95 Oct<\/div>\n<p>&#8230;<\/p>\n<div>;<br \/>\nRUN;<br \/>\nPROC SORT; BY COUNTRY;<br \/>\nPROC FREQ DATA=GRAPH2;WEIGHT TOTDTH; TABLES MONTH*COUNTRY;<br \/>\nRUN;<br \/>\n<strong>* NOTICE THE WEIGHT STATEMENT IS USED WHEN THE RAW DATA ARE SUMS;<\/strong><br \/>\nPROC SGPLOT DATA=GRAPH2;<br \/>\nTITLE1 &#8216;BUBBLE PLOT&#8217;;<br \/>\nTITLE2 &#8216;EXAMPLE 1: TOTAL DEATHS BY COUNTRY&#8217;;<br \/>\nBUBBLE X = COUNTRY Y = TOTDTH SIZE = TOTDTH \/ GROUP = MONTH TRANSPARENCY = 0.5;<br \/>\nFOOTNOTE1 J=L &#8220;SOURCE: HTTPS:\/\/DATA.HUMDATA.ORG\/DATASET\/NUMBER-OF-HEALTH-CARE-WORKERS-DEATHS-BY-EDV&#8221;;PROC SGPLOT DATA=GRAPH2;<br \/>\nTITLE1 &#8216;BUBBLE PLOT&#8217;;<br \/>\nTITLE2 &#8216;EXAMPLE 2: TOTAL DEATHS BY MONTH&#8217;;<br \/>\nBUBBLE X = MONTH Y = TOTDTH SIZE = TOTDTH \/ GROUP = COUNTRY TRANSPARENCY = 0.5; YAXIS GRID\u00a0\u00a0\u00a0 ;<br \/>\nRUN;<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>The summary frequency distribution is presented here first.<\/p>\n<table class=\"grid aligncenter\" style=\"border-collapse: collapse;width: 100%;height: 711px\">\n<thead>\n<tr class=\"shaded\" style=\"height: 15px\">\n<td style=\"width: 13.6201%;height: 15px\">Month<\/td>\n<td style=\"width: 13.6201%;height: 15px;text-align: center\">Guinea<\/td>\n<td style=\"width: 13.7993%;height: 15px;text-align: center\">Liberia<\/td>\n<td style=\"width: 13.2616%;height: 15px;text-align: center\">Mali<\/td>\n<td style=\"width: 13.9785%;height: 15px;text-align: center\">Nigeria<\/td>\n<td style=\"width: 18.8172%;height: 15px;text-align: center\">Sierra_Leone<\/td>\n<td style=\"width: 13.6201%;height: 15px;text-align: center\">Total<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"border\" style=\"height: 163px\">\n<td style=\"width: 13.6201%;height: 163px\">Sept<\/td>\n<td style=\"width: 13.6201%;height: 163px;text-align: center\">f= 127<\/p>\n<p>% total = 2.41<\/p>\n<p>row % = 17.79<\/p>\n<p>col % = 13.66<\/td>\n<td style=\"width: 13.7993%;height: 163px;text-align: center\">f= 1056<\/p>\n<p>% total =20.02<\/p>\n<p>row % = 48.89<\/p>\n<p>col % = 41.23<\/td>\n<td style=\"width: 13.2616%;height: 163px;text-align: center\">f= 12<\/p>\n<p>% total =0.23<\/p>\n<p>row % = 0.56<\/p>\n<p>col % = 85.71<\/td>\n<td style=\"width: 13.9785%;height: 163px;text-align: center\">f= 30<\/p>\n<p>% total =0.57<\/p>\n<p>row % = 1.39<\/p>\n<p>col % = 35.29<\/td>\n<td style=\"width: 18.8172%;height: 163px;text-align: center\">f= 650<\/p>\n<p>% total\u00a0 =12.32<\/p>\n<p>row % = 30.09<\/p>\n<p>col % =\u00a0 38.60<\/td>\n<td style=\"width: 13.6201%;text-align: center;height: 163px\">f= 2160<\/p>\n<p>% total =40.96<\/td>\n<\/tr>\n<tr style=\"height: 163px\">\n<td style=\"width: 13.6201%;height: 163px\">Oct<\/td>\n<td style=\"width: 13.6201%;height: 163px\">f= 124<\/p>\n<p>% total = 2.35<\/p>\n<p>row % = 16.49<\/p>\n<p>col % = 13.33<\/td>\n<td style=\"width: 13.7993%;height: 163px\">f= 322<\/p>\n<p>% total = 6.11<\/p>\n<p>row % = 42.82<\/p>\n<p>col % = 12.57<\/td>\n<td style=\"width: 13.2616%;height: 163px\">f= 0<\/p>\n<p>% total = 0.00<\/p>\n<p>row % = 0.00<\/p>\n<p>col % = 0.00<\/td>\n<td style=\"width: 13.9785%;height: 163px\">f= 15<\/p>\n<p>% total = 0.28<\/p>\n<p>row % = 1.99<\/p>\n<p>col % = 17.65<\/td>\n<td style=\"width: 18.8172%;height: 163px\">f= 291<\/p>\n<p>% total =\u00a0 5.52<\/p>\n<p>row % = 38.70<\/p>\n<p>col % =\u00a0 \u00a0 17.28<\/td>\n<td style=\"width: 13.6201%;height: 163px\">f= 752<\/p>\n<p>row % = 14.26<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<tr style=\"height: 148px\">\n<td style=\"width: 13.6201%;height: 148px\">Nov<\/td>\n<td style=\"width: 13.6201%;height: 148px\">f= 267<\/p>\n<p>% total = 5.06<\/p>\n<p>row % = 16.20<\/p>\n<p>col % = 28.71<\/td>\n<td style=\"width: 13.7993%;height: 148px\">f= 835<\/p>\n<p>% total = 15.83<\/p>\n<p>row % = 50.67<\/p>\n<p>col % = 32.60<\/td>\n<td style=\"width: 13.2616%;height: 148px\">f= 2<\/p>\n<p>% total = 0.04<\/p>\n<p>row % = 0.12<\/p>\n<p>col % = 14.29<\/td>\n<td style=\"width: 13.9785%;height: 148px\">f= 25<\/p>\n<p>% total = 0.47<\/p>\n<p>row % = 1.52<\/p>\n<p>col % = 29.41<\/td>\n<td style=\"width: 18.8172%;height: 148px\">f= 519<\/p>\n<p>% total =\u00a0 9.84<\/p>\n<p>row % =\u00a0 31.49<\/p>\n<p>col % =\u00a0 \u00a030.82<\/td>\n<td style=\"width: 13.6201%;height: 148px\">f= 1648<\/p>\n<p>row % =31.25<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<tr style=\"height: 148px\">\n<td style=\"width: 13.6201%;height: 148px\">Dec<\/td>\n<td style=\"width: 13.6201%;height: 148px\">f= 412<\/p>\n<p>% total = 7.81<\/p>\n<p>row % = 19.07<\/p>\n<p>col % = 44.30<\/td>\n<td style=\"width: 13.7993%;height: 148px\">f= 1056<\/p>\n<p>% total = 20.02<\/p>\n<p>row % = 48.89<\/p>\n<p>col % = 41.23<\/td>\n<td style=\"width: 13.2616%;height: 148px\">f= 12<\/p>\n<p>% total = 0.23<\/p>\n<p>row % = 0.56<\/p>\n<p>col % = 85.71<\/td>\n<td style=\"width: 13.9785%;height: 148px\">f= 30<\/p>\n<p>% total = 0.57<\/p>\n<p>row % = 1.39<\/p>\n<p>col % = 35.29<\/td>\n<td style=\"width: 18.8172%;height: 148px\">f= 650<\/p>\n<p>% total = 12.32<\/p>\n<p>row % = 30.09<\/p>\n<p>col % =\u00a0 38.60<\/td>\n<td style=\"width: 13.6201%;height: 148px\">f= 2160<\/p>\n<p>row % = 40.96<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<tr style=\"height: 74px\">\n<td style=\"width: 13.6201%;height: 74px\">Total<\/td>\n<td style=\"width: 13.6201%;height: 74px\">f= 930<\/p>\n<p>col % = 17.63<\/td>\n<td style=\"width: 13.7993%;height: 74px\">f= 2561<\/p>\n<p>col % = 48.56<\/td>\n<td style=\"width: 13.2616%;height: 74px\">f= 14<\/p>\n<p>col % = 0.27<\/td>\n<td style=\"width: 13.9785%;height: 74px\">f= 85<\/p>\n<p>col % = 1.61<\/td>\n<td style=\"width: 18.8172%;height: 74px\">f= 1684<\/p>\n<p>col % =\u00a0 \u00a031.93<\/td>\n<td style=\"width: 13.6201%;height: 74px\">f= 5274<\/p>\n<p>100.00<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Bubble plots can be used to illustrate the distribution of outcomes within specific groups.\u00a0 In the following two graphs the data from the summary frequency table of <em>month by country<\/em> above, which showed deaths within the countries monitored across months are presented using two different grouping strategies. In the first example (bubble plot example 1) the data showing the number of deaths (Y-axis) are separated using countries as the main X-Axis variable and months as the grouping variable.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble1.png\" alt=\"\" class=\"aligncenter size-full wp-image-1408\" width=\"1337\" height=\"1004\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble1.png 1337w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble1-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble1-1024x769.png 1024w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble1-768x577.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble1-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble1-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble1-350x263.png 350w\" sizes=\"auto, (max-width: 1337px) 100vw, 1337px\" \/>The specific SAS code is:<\/p>\n<div>\n<div class=\"textbox shaded\">PROC SGPLOT DATA=GRAPH2;<br \/>\nTITLE1 &#8216;BUBBLE PLOT&#8217;;<br \/>\nTITLE2 &#8216;EXAMPLE 1: TOTAL DEATHS BY COUNTRY&#8217;;<br \/>\nBUBBLE X = COUNTRY Y = TOTDTH SIZE = TOTDTH \/ GROUP = MONTH TRANSPARENCY = 0.5;FOOTNOTE1 J=L &#8220;SOURCE: HTTPS:\/\/DATA.HUMDATA.ORG\/DATASET\/NUMBER-OF-HEALTH-CARE-WORKERS-DEATHS-BY-EDV&#8221;;<\/div>\n<\/div>\n<p>In the second example (bubble plot example 2) the data showing the number of deaths (Y-axis) are separated using months as the main X-axis variable and country in which the deaths occurred is the grouping variable.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble2.png\" alt=\"\" class=\"aligncenter size-full wp-image-1410\" width=\"1187\" height=\"889\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble2.png 1187w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble2-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble2-1024x767.png 1024w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble2-768x575.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble2-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble2-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/bubble2-350x262.png 350w\" sizes=\"auto, (max-width: 1187px) 100vw, 1187px\" \/><\/p>\n<p>The specific SAS code is presented here. Notice we did not need to repeat the footnote statement from Bubble Plot 1 for it to be included in Bubble Plot 2 because the RUN; statement was held until the end of the program.<\/p>\n<div>\n<div class=\"textbox shaded\">PROC SGPLOT DATA=GRAPH2;<br \/>\nTITLE1 &#8216;BUBBLE PLOT&#8217;;<br \/>\nTITLE2 &#8216;EXAMPLE 2: TOTAL DEATHS BY MONTH&#8217;;<br \/>\nBUBBLE X = MONTH Y = TOTDTH SIZE = TOTDTH \/ GROUP = COUNTRY TRANSPARENCY = 0.5; YAXIS GRID\u00a0\u00a0\u00a0 ;<br \/>\nRUN;<\/div>\n<\/div>\n<hr \/>\n<h1>Producing Star Charts<\/h1>\n<p>In this SAS graphing procedure we show how out of balance sedentary behaviour can be in comparison to other activities of daily living.<\/p>\n<p>Primary healthcare has continued to support the notion that sedentary behaviours are major risk factors for most chronic diseases.\u00a0 In particular, there has been a growing awareness of the relationship between sitting for prolonged periods during the day as a risk factor for chronic diseases such as CVD\/CHD, type II diabetes, and hypertension. The data reported here is the estimated time in non-standing related activities. We can use a star chart to demonstrate an effective approach to representing unbalanced data for a given outcome. These data are from the American Heart Foundation (2015).<\/p>\n<p>The SAS code to generate a horizontal bar chart with a corresponding frequency distribution table and two different star graphs are shown below. Notice in this SAS code we predefine the length of the input data for the variable BEHAVIOR and we use a fixed input format to enter the data values for the variables TIME in columns 22 to 24 and the variable GROUP in columns 27 to 28.<\/p>\n<div class=\"textbox shaded\">\n<p>DATA STARS;<br \/>\nLENGTH BEHAV $20.;<br \/>\nINPUT BEHAV $ 1-20 TIME 22-24 GRP 27-28 ;<br \/>\nLABEL TIME=&#8217;TIME (HOURS)&#8217;;\u00a0 LABEL BEHAV=&#8217;BEHAVIOUR&#8217;;<br \/>\nDATALINES;<br \/>\nMORNING_WALK\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.5\u00a0 1<br \/>\nDRIVE_TO_WORK\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.0\u00a0 1<br \/>\nAM_COMPUTER_TIME\u00a0\u00a0\u00a0\u00a0 4.0\u00a0 1<br \/>\nLUNCHTIME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.5\u00a0 1<br \/>\nPM_COMPUTER_TIME\u00a0\u00a0\u00a0\u00a0 4.0\u00a0 1<br \/>\nDRIVE_HOME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.0\u00a0 2<br \/>\nSTRENGTH_TRAINING\u00a0\u00a0\u00a0 0.5\u00a0 2<br \/>\nDINNERTIME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.5\u00a0 2<br \/>\nRELAX_TV_OR_READ\u00a0\u00a0\u00a0\u00a0 4.0\u00a0 2<br \/>\nBEDTIME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8.0\u00a0 2<br \/>\n;<br \/>\nPROC GCHART;<br \/>\nHBAR BEHAV\/SUMVAR=TIME;<br \/>\nTITLE1 &#8220;HOURS SPENT IN SEDENTARY BEHAVIOUR-HORIZONTAL BAR CHART&#8221;;<br \/>\nRUN;<\/p>\n<p>PROC GCHART ;<br \/>\nTITLE1 &#8220;EXAMPLE STAR GRAPH 1&#8221;;<br \/>\nTITLE2 &#8220;HOURS SPENT IN SEDENTARY BEHAVIOUR&#8221;;<br \/>\nSTAR BEHAV \/ DISCRETE SUMVAR=TIME FILL=S;<br \/>\nRUN;<\/p>\n<p>PROC GCHART ;<br \/>\nSTAR BEHAV \/ DISCRETE SUMVAR=TIME NOCONNECT;<br \/>\nTITLE1 &#8220;EXAMPLE STAR GRAPH 2&#8221;;<br \/>\nTITLE2 &#8220;HOURS SPENT IN SEDENTARY BEHAVIOUR&#8221;;<br \/>\nRUN;<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star1.png\" alt=\"\" class=\"aligncenter size-full wp-image-1414\" width=\"1110\" height=\"833\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star1.png 1110w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star1-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star1-1024x768.png 1024w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star1-768x576.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star1-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star1-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star1-350x263.png 350w\" sizes=\"auto, (max-width: 1110px) 100vw, 1110px\" \/><\/p>\n<div class=\"textbox textbox--exercises\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">In the image above we include the FILL=S; option in the SAS code<\/p>\n<\/header>\n<div class=\"textbox__content\">PROC GCHART ;<br \/>\nTITLE1 &#8220;EXAMPLE STAR GRAPH 1&#8221;;<br \/>\nTITLE2 &#8220;HOURS SPENT IN SEDENTARY BEHAVIOUR&#8221;;<br \/>\nSTAR BEHAV \/ DISCRETE SUMVAR=TIME FILL=S;<\/div>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star2.png\" alt=\"\" class=\"aligncenter size-full wp-image-1415\" width=\"1122\" height=\"818\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star2.png 1122w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star2-300x219.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star2-1024x747.png 1024w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star2-768x560.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star2-65x47.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star2-225x164.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/star2-350x255.png 350w\" sizes=\"auto, (max-width: 1122px) 100vw, 1122px\" \/><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div class=\"textbox textbox--exercises\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">In the image above we <em>we <strong>remove<\/strong> the <\/em><em>FILL=S<\/em><em> option and <strong>include<\/strong> the <\/em><em>NOCONNECT <\/em><em>option <\/em>in the SAS code<\/p>\n<\/header>\n<div class=\"textbox__content\">PROC GCHART ;<br \/>\nSTAR BEHAV \/ DISCRETE SUMVAR=TIME NOCONNECT;<br \/>\nTITLE1 &#8220;EXAMPLE STAR GRAPH 2&#8221;;<br \/>\nTITLE2 &#8220;HOURS SPENT IN SEDENTARY BEHAVIOUR&#8221;;<\/div>\n<\/div>\n<div>\n<hr \/>\n<h1>Preparing data for graphing by transposing datasets<\/h1>\n<p>In this next section, we will rotate the perspective of the data set &#8212; a term we refer to as TRANSPOSING.\u00a0 With the PROC TRANSPOSE feature, we can re-orient the data set from written in a wide format to a narrow format.<\/p>\n<p>The wide-format of the dataset is shown in the table below. With the SAS code below we can transpose four variables into one variable. The following table is the original four variables from the raw data.<\/p>\n<div style=\"margin: auto;\">\n<table>\n<thead>\n<tr>\n<td>Obs<\/td>\n<td>ID<\/td>\n<td>var1<\/td>\n<td>var2<\/td>\n<td>var3<\/td>\n<td>var4<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>7<\/td>\n<td>0.350<\/td>\n<td>0.326<\/td>\n<td>0.333<\/td>\n<td>0.333<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>9<\/td>\n<td>0.346<\/td>\n<td>0.328<\/td>\n<td>0.318<\/td>\n<td>0.325<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>10<\/td>\n<td>0.350<\/td>\n<td>0.352<\/td>\n<td>0.345<\/td>\n<td>0.355<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>11<\/td>\n<td>0.345<\/td>\n<td>0.330<\/td>\n<td>0.341<\/td>\n<td>0.321<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>13<\/td>\n<td>0.348<\/td>\n<td>0.342<\/td>\n<td>0.335<\/td>\n<td>0.330<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>14<\/td>\n<td>0.347<\/td>\n<td>0.334<\/td>\n<td>0.342<\/td>\n<td>0.350<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>15<\/td>\n<td>0.349<\/td>\n<td>0.325<\/td>\n<td>0.324<\/td>\n<td>0.327<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>16<\/td>\n<td>0.338<\/td>\n<td>0.322<\/td>\n<td>0.334<\/td>\n<td>0.324<\/td>\n<\/tr>\n<tr>\n<td>9<\/td>\n<td>18<\/td>\n<td>0.331<\/td>\n<td>0.329<\/td>\n<td>0.314<\/td>\n<td>0.335<\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td>19<\/td>\n<td>0.342<\/td>\n<td>0.332<\/td>\n<td>0.323<\/td>\n<td>0.328<\/td>\n<\/tr>\n<tr>\n<td>11<\/td>\n<td>20<\/td>\n<td>0.338<\/td>\n<td>0.318<\/td>\n<td>0.325<\/td>\n<td>0.331<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<div class=\"textbox textbox--examples\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">SAS Code to transpose the data from a wide to a narrow format<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<p>DATA TRNSPS_W2N;<br \/>\n\/* TRANSPOSING WIDE DATA TO NARROW DATA *\/<br \/>\nINPUT ID VAR1 VAR2 VAR3 VAR4;<br \/>\nDATALINES;<br \/>\n7 0.35 0.326 0.333 0.333<br \/>\n9 0.346 0.328 0.318 0.325<br \/>\n10 0.35 0.352 0.345 0.355<br \/>\n11 0.345 0.33 0.341 0.321<br \/>\n13 0.348 0.342 0.335 0.33<br \/>\n14 0.347 0.334 0.342 0.35<br \/>\n15 0.349 0.325 0.324 0.327<br \/>\n16 0.338 0.322 0.334 0.324<br \/>\n18 0.331 0.329 0.314 0.335<br \/>\n19 0.342 0.332 0.323 0.328<br \/>\n20 0.338 0.318 0.325 0.331<br \/>\n;<\/p>\n<p>TITLE1 &#8216;TRANSPOSING FOUR VARIABLES INTO ONE VARIABLE&#8217;;<br \/>\nPROC SORT DATA=TRNSPS_W2N; BY ID;<br \/>\nTITLE2 &#8216;PRINT OF THE ORIGINAL FOUR VARIABLES FROM THE RAW DATA&#8217;;<br \/>\nPROC PRINT; VAR ID VAR1 VAR2 VAR3 VAR4 ;<br \/>\nRUN;<br \/>\nPROC TRANSPOSE DATA=TRNSPS_W2N OUT=NARROW;<br \/>\nBY ID;<\/p>\n<p>TITLE2 &#8216;PRINT OF THE TRANSPOSED DATA TO A SINGLE VARIABLE&#8217;;<br \/>\nRUN;<br \/>\nPROC PRINT DATA=NARROW; VAR ID \u00a0\u00a0 _NAME_ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 COL1;<br \/>\nRUN;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>A portion of the narrow format of the data is shown here in this printout of the transposed data. Here we show the four variables as one categorical variable and one outcome variable, which can then be graphed.<\/p>\n<\/div>\n<\/div>\n<div>\n<div>\n<div style=\"margin: auto;\">\n<table>\n<thead>\n<tr>\n<td>Obs<\/td>\n<td>ID<\/td>\n<td>_NAME_<\/td>\n<td>COL1<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>7<\/td>\n<td>var1<\/td>\n<td>0.350<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>7<\/td>\n<td>var2<\/td>\n<td>0.326<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>7<\/td>\n<td>var3<\/td>\n<td>0.333<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>7<\/td>\n<td>var4<\/td>\n<td>0.333<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>9<\/td>\n<td>var1<\/td>\n<td>0.346<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>9<\/td>\n<td>var2<\/td>\n<td>0.328<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>9<\/td>\n<td>var3<\/td>\n<td>0.318<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>9<\/td>\n<td>var4<\/td>\n<td>0.325<\/td>\n<\/tr>\n<tr>\n<td>9<\/td>\n<td>10<\/td>\n<td>var1<\/td>\n<td>0.350<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>The data in the transposed table above can be used in a graph to show the response of each participant for the single dependent variable, which we called SCORE, across four measures. The SGPLOT procedure was modified from SAS SUPPORT CODE: Sample <em>50217: <\/em>Plot means with standard error bars from calculated data for groups with PROC GPLOT<a href=\"#_ftn1\">[1]<\/a>.<\/p>\n<div class=\"textbox textbox--examples\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">SAS Code for Wide to Narrow<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<div>\n<p>PROC FORMAT;<br \/>\nVALUE CNDFMT 1 = &#8216;CONDITION 1&#8217;<br \/>\n2 = &#8216;CONDITION 2&#8217;<br \/>\n3 = &#8216;CONDITION 3&#8217;<br \/>\n4 = &#8216;CONDITION 4&#8217; ;<\/p>\n<p>\/* PLOT OF DEPENDENT VARIABLE AFTER TRANSPOSE TO NARROW DATA *\/<br \/>\nDATA W2N;<br \/>\nINPUT OBS ID COND SCORE;<br \/>\n\/* USE THE TRANSPOSED DATASET IN A LINE GRAPH ACROSS 4 CONDITIONS *\/<br \/>\nDATALINES;<br \/>\n1 7\u00a0 1 0.350<br \/>\n2 7\u00a0 2 0.326<\/p>\n<p>&lt;MORE DATA HERE &gt;<\/p>\n<p>41 20\u00a0 1 0.338<br \/>\n42 20\u00a0 2 0.318<br \/>\n43 20\u00a0 3 0.325<br \/>\n44 20 \u00a04 0.331<br \/>\n;<br \/>\nTITLE1 &#8216;TRANSPOSING FOUR VARIABLES INTO ONE VARIABLE&#8217;;<br \/>\nTITLE2 &#8216;TRANSPOSED VARIABLE AS A SINGLE RESPONSE ACROSS FOUR TIME POINTS&#8217;;<br \/>\nAXIS1 ORDER=(1 TO 4 BY 0.55) OFFSET=(2,2)<br \/>\nLABEL=NONE\u00a0 MAJOR=(HEIGHT=2) MINOR=(HEIGHT=1);<br \/>\nAXIS2 ORDER=(0.3 TO 0.4 BY 0.01) OFFSET=(0,0)<br \/>\nLABEL=NONE\u00a0\u00a0 MAJOR=(HEIGHT=2) MINOR=(HEIGHT=1);<br \/>\nRUN;<br \/>\nPROC SORT DATA=W2N; BY COND;<br \/>\nPROC MEANS DATA=W2N\u00a0 NOPRINT;<br \/>\nBY COND;<br \/>\nVAR SCORE;<br \/>\nOUTPUT OUT=MEANSOUT MEAN=MEAN STDERR=STDERR;<br \/>\nTITLE1 &#8216;DESCRIPTIVE STATISTICS FOR SCORE ACROSS 4 CONDITIONS&#8217;;<br \/>\nRUN;<br \/>\n\/* RESHAPE THE DATA TO PRESENT ONE Y VALUE FOR *\/<br \/>\n\/* EACH X FOR USE WITH THE HILOC INTERPOLATION.\u00a0\u00a0 *\/<br \/>\nDATA RESHAPE(KEEP=COND SCORE MEAN);<br \/>\nSET MEANSOUT;<br \/>\nSCORE=MEAN;<br \/>\nOUTPUT;<br \/>\nSCORE=MEAN &#8211; STDERR;<br \/>\nOUTPUT;<br \/>\nSCORE=MEAN + STDERR;<br \/>\nOUTPUT;<br \/>\nRUN;<br \/>\n\/* DEFINE THE TITLE *\/<br \/>\nTITLE1 &#8216;PLOT OF MEANS WITH STANDARD ERROR BARS FOR SCORE ACROSS CONDITIONS&#8217;;<br \/>\n\/* DEFINE THE AXIS CHARACTERISTICS *\/<br \/>\nAXIS1 OFFSET=(5,5) MINOR=NONE;<br \/>\nAXIS2 LABEL=(ANGLE=90);<br \/>\n\/* DEFINE THE SYMBOL CHARACTERISTICS *\/<br \/>\nSYMBOL1 INTERPOL=HILOCTJ COLOR=BLUE LINE=2;<br \/>\nSYMBOL2 INTERPOL=NONE COLOR=BLUE VALUE=DOT HEIGHT=1.5;<br \/>\n\/* PLOT THE ERROR BARS USING THE HILOCTJ INTERPOLATION *\/<br \/>\n\/* AND OVERLAY SYMBOLS AT THE MEANS. *\/<br \/>\nPROC GPLOT DATA=RESHAPE;<br \/>\nPLOT SCORE*COND MEAN*COND \/ OVERLAY HAXIS=AXIS1 VAXIS=AXIS2;<br \/>\nFORMAT COND CNDFMT.;<br \/>\nRUN;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>This SAS code from the transposed dataset produced the following graph.<\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/wide2n.png\" alt=\"\" class=\"aligncenter size-full wp-image-1424\" width=\"1000\" height=\"750\" srcset=\"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/wide2n.png 1000w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/wide2n-300x225.png 300w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/wide2n-768x576.png 768w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/wide2n-65x49.png 65w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/wide2n-225x169.png 225w, https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-content\/uploads\/sites\/49\/2020\/04\/wide2n-350x263.png 350w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/>Transposing data from narrow to a wide format<\/h2>\n<p>Consider now if our data were in a long format, as in a single column with 3 categories but we wanted to reshape the data so that each of the categories became a separate measure of interest.\u00a0 In the following data set consisting of a categorical variable that we called employment status and a dependent variable based on household savings in the bank on January 1. Here, we will transpose the data from a long format to a wide format and convert the initial measure of interest to three variables.<\/p>\n<p>The initial SAS code with data is as follows<a href=\"#_ftn2\">[2]<\/a>:<\/p>\n<div>\n<div class=\"textbox textbox--examples\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">SAS Code for Narrow to Wide<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<p>PROC FORMAT;<br \/>\nVALUE EMP 1= &#8216;FULL-TIME&#8217; 2 = &#8216;PART-TIME&#8217; 3= &#8216;CASUAL&#8217;;<br \/>\nDATA EMPSTAT;<br \/>\nLABEL\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ID = &#8216;PARTICIPANT ID&#8217;<br \/>\nEMPSTAT = &#8216;EMPLOYMENT STATUS&#8217;<br \/>\nSAVINGS = &#8216;SAVINGS IN BANK&#8217;;<br \/>\nINPUT ID 1-2 EMPSTAT 4 SAVINGS 6-9;<br \/>\nDATALINES;<br \/>\n01 3 0020<br \/>\n02 1 0120<br \/>\n03 2 0050<br \/>\n04 3 0030<br \/>\n05 3 0000<br \/>\n06 1 4500<br \/>\n07 1 8900<br \/>\n08 2 0540<br \/>\n09 3 0900<br \/>\n10 1 3220<br \/>\n11 2 0240<br \/>\n12 2 0400<br \/>\n;<br \/>\nPROC SORT data=EMPSTAT; BY EMPSTAT;<br \/>\nPROC FREQ; TABLES EMPSTAT;<br \/>\nFORMAT EMPSTAT EMP. ;<br \/>\nPROC FREQ; TABLES EMPSTAT*SAVINGS;<br \/>\nFORMAT EMPSTAT EMP. ;<br \/>\nTITLE1 &#8216; FREQUENCY DISTRIBUTION FOR EMPLOYMENT STATUS&#8217;;<br \/>\nRUN;<br \/>\nPROC SORT data=EMPSTAT; BY ID;<br \/>\nPROC TRANSPOSE data=EMPSTAT out=NEW_WIDE prefix=GROUP_;<br \/>\nby ID ;<br \/>\nid EMPSTAT;<br \/>\nvar SAVINGS;<br \/>\nRUN;<br \/>\nproc print data = NEW_WIDE; VAR ID GROUP_1 GROUP_2 GROUP_3;<br \/>\nTITLE &#8216;OUTPUT FOR WIDE FORMATTED DATA&#8217;;<br \/>\nRUN;<br \/>\nPROC MEANS MEAN MEDIAN STD STDERR CV; VAR GROUP_1 GROUP_2 GROUP_3;<br \/>\nTITLE &#8216;USING PROC MEANS- DESCRIPTIVE STATISTICS FOR WIDE FORMATTED DATA&#8217;;<br \/>\nRUN;<br \/>\nPROC TABULATE data = NEW_WIDE;<br \/>\nLABEL GROUP_1 = &#8216;EMPLOYED FULL TIME&#8217;<br \/>\nGROUP_2 = &#8216;EMPLOYED PART TIME&#8217;<br \/>\nGROUP_3 = &#8216;EMPLOYED CASUALLY&#8217;;<br \/>\nVAR GROUP_1 GROUP_2 GROUP_3;<br \/>\nTABLE (GROUP_1 GROUP_2 GROUP_3)* (N MEAN STD CV);<br \/>\nTITLE &#8216;USING PROC TABULATE &#8211; DESCRIPTIVE STATISTICS FOR WIDE FORMATTED DATA&#8217;;<br \/>\nRUN;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>The SAS code above produced the following output after transposing the data from the dependent variable to produce three measures of interest which we called GROUP_1 GROUP_2 and GROUP_3. Each variable now represents the data within the specific employment category and the PROC TABULATE and PROC MEANS commands were used to produce descriptive statistics for each separate dependent measure.<\/p>\n<p>FREQUENCY DISTRIBUTION FOR EMPLOYMENT STATUS<\/p>\n<table class=\"landscape aligncenter\" style=\"border-collapse: collapse;width: 100%;height: 75px\">\n<thead>\n<tr class=\"shaded\" style=\"height: 30px\">\n<td style=\"width: 20%;height: 30px;text-align: center\">EMPLOYMENT STATUS<\/td>\n<td style=\"width: 20%;height: 30px;text-align: center\">FREQUENCY<\/td>\n<td style=\"width: 20%;height: 30px;text-align: center\">PERCENT<\/td>\n<td style=\"width: 20%;height: 30px;text-align: center\">CUMULATIVE FREQUENCY<\/td>\n<td style=\"width: 20%;height: 30px;text-align: center\">CUMULATIVE PERCENT<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 15px\">\n<td style=\"width: 20%;height: 15px\">FULL TIME<\/td>\n<td style=\"width: 20%;height: 15px\">4<\/td>\n<td style=\"width: 20%;height: 15px\">33,33<\/td>\n<td style=\"width: 20%;height: 15px\">4<\/td>\n<td style=\"width: 20%;height: 15px\">33.33<\/td>\n<\/tr>\n<tr style=\"height: 15px\">\n<td style=\"width: 20%;height: 15px\">PART-TIME<\/td>\n<td style=\"width: 20%;height: 15px\">4<\/td>\n<td style=\"width: 20%;height: 15px\">33.33<\/td>\n<td style=\"width: 20%;height: 15px\">8<\/td>\n<td style=\"width: 20%;height: 15px\">33.33<\/td>\n<\/tr>\n<tr style=\"height: 15px\">\n<td style=\"width: 20%;height: 15px\">CASUAL<\/td>\n<td style=\"width: 20%;height: 15px\">4<\/td>\n<td style=\"width: 20%;height: 15px\">33.33<\/td>\n<td style=\"width: 20%;height: 15px\">12<\/td>\n<td style=\"width: 20%;height: 15px\">100<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>USING PROC MEANS TO PRODUCE DESCRIPTIVE STATISTICS FOR WIDE FORMATTED DATA<\/p>\n<p>The MEANS Procedure<\/p>\n<div style=\"margin: auto;\">\n<table class=\"lines aligncenter\" style=\"height: 145px; width: 439px;\">\n<thead>\n<tr class=\"shaded\">\n<td style=\"text-align: center;width: 70.25px\">Variable<\/td>\n<td style=\"text-align: center;width: 51.85px\">Mean<\/td>\n<td style=\"text-align: center;width: 57.45px\">Median<\/td>\n<td style=\"text-align: center;width: 51.85px\">Std Dev<\/td>\n<td style=\"text-align: center;width: 54.25px\">Std Error<\/td>\n<td style=\"text-align: center;width: 73.45px\">Coeff of Variation<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"border\">\n<td style=\"width: 70.25px;text-align: center\">GROUP_1<\/p>\n<p>GROUP_2<\/p>\n<p>GROUP_3<\/td>\n<td style=\"width: 51.85px;text-align: center\">4185.00<\/p>\n<p>307.50<\/p>\n<p>237.50<\/td>\n<td style=\"width: 57.45px;text-align: center\">3860.00<\/p>\n<p>320.00<\/p>\n<p>25.00<\/td>\n<td style=\"width: 51.85px;text-align: center\">3641.70<\/p>\n<p>210.93<\/p>\n<p>441.84<\/td>\n<td style=\"width: 54.25px;text-align: center\">1820.85<\/p>\n<p>105.47<\/p>\n<p>220.92<\/td>\n<td style=\"width: 73.45px;text-align: center\">87.01<\/p>\n<p>68.60<\/p>\n<p>186.04<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>USING PROC TABULATE \u2013DESCRIPTIVE STATISTICS FOR WIDE FORMATTED DATA<\/p>\n<h2 id=\"tablepress-14-name\" class=\"tablepress-table-name tablepress-table-name-id-14\">DESCRIPTIVE STATISTICS CALCULATED WITH PROC TABULATE<\/h2>\n<table id=\"tablepress-14\" class=\"tablepress tablepress-id-14\" aria-labelledby=\"tablepress-14-name\" aria-describedby=\"tablepress-14-description\">\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-1\">\n<td class=\"column-1\">EMPLOYED FULL TIME<\/td>\n<td class=\"column-2\"><\/td>\n<td class=\"column-3\"><\/td>\n<td class=\"column-4\"><\/td>\n<\/tr>\n<tr class=\"row-2\">\n<td class=\"column-1\">N<\/td>\n<td class=\"column-2\">MEAN<\/td>\n<td class=\"column-3\">STANDARD DEVIATION<\/td>\n<td class=\"column-4\">COEFFICIENT OF VARIATION<\/td>\n<\/tr>\n<tr class=\"row-3\">\n<td class=\"column-1\">4<\/td>\n<td class=\"column-2\">4185<\/td>\n<td class=\"column-3\">3641.7<\/td>\n<td class=\"column-4\">87.02<\/td>\n<\/tr>\n<tr class=\"row-4\">\n<td class=\"column-1\">EMPLOYED PART TIME<\/td>\n<td class=\"column-2\"><\/td>\n<td class=\"column-3\"><\/td>\n<td class=\"column-4\"><\/td>\n<\/tr>\n<tr class=\"row-5\">\n<td class=\"column-1\">N<\/td>\n<td class=\"column-2\">MEAN<\/td>\n<td class=\"column-3\">STANDARD DEVIATION<\/td>\n<td class=\"column-4\">COEFFICIENT OF VARIATION<\/td>\n<\/tr>\n<tr class=\"row-6\">\n<td class=\"column-1\">4<\/td>\n<td class=\"column-2\">307.5<\/td>\n<td class=\"column-3\">210.93<\/td>\n<td class=\"column-4\">68.6<\/td>\n<\/tr>\n<tr class=\"row-7\">\n<td class=\"column-1\">EMPLOYED CASUALLY<\/td>\n<td class=\"column-2\"><\/td>\n<td class=\"column-3\"><\/td>\n<td class=\"column-4\"><\/td>\n<\/tr>\n<tr class=\"row-8\">\n<td class=\"column-1\">N<\/td>\n<td class=\"column-2\">MEAN<\/td>\n<td class=\"column-3\">STANDARD DEVIATION<\/td>\n<td class=\"column-4\">COEFFICIENT OF VARIATION<\/td>\n<\/tr>\n<tr class=\"row-9\">\n<td class=\"column-1\">4<\/td>\n<td class=\"column-2\">237.5<\/td>\n<td class=\"column-3\">441.84<\/td>\n<td class=\"column-4\">186.04<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span id=\"tablepress-14-description\" class=\"tablepress-table-description tablepress-table-description-id-14\">A first look at the features of SAS PROC TABULATE<\/span><br \/>\n<!-- #tablepress-14 from cache --><\/p>\n<div>\n<div>\n<hr \/>\n<p><a href=\"#_ftnref1\">[1]<\/a> http:\/\/support.sas.com\/kb\/50\/217.html<\/p>\n<\/div>\n<div>\n<p><a href=\"#_ftnref2\">[2]<\/a> The structure of this code was derived from: Introduction to SAS. UCLA: Statistical Consulting Group.from https:\/\/stats.idre.ucla.edu\/sas\/modules\/sas-learning-moduleintroduction-to-the-features-of-sas\/ (accessed August 22, 2016).<\/p>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<div>\n<div>\n<p><a href=\"#_ftnref1\">[1]<\/a> (URL \u2013 https:\/\/data.humdata.org\/dataset\/number-of-health-care-workers-deaths-by-edv) a project from the United Nations Office for the Coordination of Humanitarian Aid (url: http:\/\/www.unocha.org\/)<\/p>\n<\/div>\n<\/div>\n<hr \/>\n<\/div>\n<div><\/div>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"author":56,"menu_order":5,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-414","chapter","type-chapter","status-publish","hentry"],"part":180,"_links":{"self":[{"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/pressbooks\/v2\/chapters\/414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/wp\/v2\/users\/56"}],"version-history":[{"count":79,"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/pressbooks\/v2\/chapters\/414\/revisions"}],"predecessor-version":[{"id":2105,"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/pressbooks\/v2\/chapters\/414\/revisions\/2105"}],"part":[{"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/pressbooks\/v2\/parts\/180"}],"metadata":[{"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/pressbooks\/v2\/chapters\/414\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/wp\/v2\/media?parent=414"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/pressbooks\/v2\/chapter-type?post=414"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/wp\/v2\/contributor?post=414"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.library.upei.ca\/montelpare\/wp-json\/wp\/v2\/license?post=414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}