Published on :

Characteristics of Subjects in the Study

This code is also available in: Deutsch Español Français
The script initializes the Output Delivery System (ODS) to produce graphical output. It defines a statistical graph template (`STATGRAPH`) named `Fig_8_0_PatientProfile` using `PROC TEMPLATE`. This template arranges a scatter plot (cholesterol vs. systolic blood pressure) and bar/box plots (average weight, diastolic blood pressure by cause of death) in a lattice layout. Finally, `PROC SGRENDER` is used with the `sashelp.heart` dataset to apply this template and generate the resulting graph as an image.
Data Analysis

Type : SASHELP


The script uses the standard `sashelp.heart` dataset from SAS, which is provided with the SAS installation and does not require an external source or internal creation.

1 Code Block
ODS Setup
Explanation :
This block initializes the Output Delivery System (ODS) options. It defines an output path for images (`gpath`), image resolution (`dpi`), and configures ODS output for HTML with an `htmlblue` style. The `ods html close;` command closes the default HTML destination to avoid conflicts when generating subsequent graphs.
Copied!
1%let gpath='.'; /*--Put your Folder Name here--*/
2%let dpi=300;
3ods listing style=htmlblue image_dpi=&dpi gpath=&gpath;
4ods html close;
2 Code Block
PROC TEMPLATE
Explanation :
This block defines a statistical graph template (`STATGRAPH`) named `Fig_8_0_PatientProfile`. The template creates a lattice layout (`layout lattice`) with two columns. The first column contains a scatter plot (`scatterplot`) of cholesterol versus systolic blood pressure, grouped by sex. The second column is another lattice superimposing a bar chart (mean weight by cause of death and sex) and a box plot (diastolic blood pressure by cause of death and sex). Various style attributes are applied to enhance the readability and aesthetics of the graph.
Copied!
1PROC TEMPLATE;
2 define statgraph Fig_8_0_PatientProfile;
3 begingraph / datacolors=(green gold)
4 datacontrastcolors=(green gold);
5 entrytitle "Characteristics of Subjects in the Study";
6 layout lattice / columns=2 columnweights=(0.6 0.4) columngutter=10px;
7 sidebar / spacefill=false;
8 discretelegend 'a';
9 endsidebar;
10 layout overlay;
11 scatterplot x=cholesterol y=systolic / group=sex name='a'
12 markerattrs=(symbol=circlefilled) datatransparency=0.5;
13 endlayout;
14 layout lattice / rows=2 columndatarange=union;
15 columnaxes;
16 columnaxis / discreteopts=(tickvaluefitpolicy=split) tickvalueattrs=(size=6);
17 endcolumnaxes;
18 layout overlay / yaxisopts=(labelattrs=(size=8) tickvalueattrs=(size=6)
19 label='Weight(mean)' offsetmin=0)
20 xaxisopts=(labelattrs=(size=8) tickvalueattrs=(size=6));
21 barchart x=deathcause y=weight / group=sex groupdisplay=cluster stat=mean
22 baselineattrs=(thickness=0) fillattrs=(transparency=0.2) outlineattrs=(color=black);
23 endlayout;
24 layout overlay / yaxisopts=(labelattrs=(size=8) tickvalueattrs=(size=6))
25 xaxisopts=(labelattrs=(size=8) tickvalueattrs=(size=6));
26 boxplot y=diastolic x=deathcause / group=sex groupdisplay=cluster
27 fillattrs=(transparency=0.2) meanattrs=(size=5 color=black) outlineattrs=(color=black);
28 endlayout;
29 endlayout;
30 endlayout;
31 endgraph;
32 END;
33RUN;
3 Code Block
PROC SGRENDER
Explanation :
This block activates the `ods listing` destination and configures `ods graphics` with specific dimensions (`width`, `height`) and an image name (`imagename`). `PROC SGRENDER` is then used to generate the graph by applying the previously defined `Fig_8_0_PatientProfile` template to the `sashelp.heart` dataset. The result is a graphic image encapsulating the template.
Copied!
1ods listing;
2ods graphics / reset width=6in height=2.4in imagename="8_0_Panel_V94";
3PROC SGRENDER DATA=sashelp.heart template=Fig_8_0_PatientProfile;
4RUN;
4 Code Block
ODS Cleanup
Explanation :
This block resets the global ODS titles and footnotes, ensuring they do not persist for subsequent ODS outputs.
Copied!
1title;
2footnote;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.