GDEVICE Procedure
Example: Creating a Custom Device Entry with Program Statements
Features: |
- COPY statement options:
- FROM=
- NEWNAME=
- MODIFY statement options:
- COLORS=
- DESCRIPTION=
|
Other features: |
LIBNAME statement
|
Sample library member: |
GDVCSTOM |
This example uses the
GDEVICE procedure statements COPY and MODIFY statements to create
a customized version of the WIN device. It copies the original entry
into a personal devices catalog and changes the device parameters.
After running this example, all output generated with the WIN device
will use the customized color list created by this example.
Pie Chart Created with Default WIN Device Entry
Pie Chart Created with Customized WIN Device Entry
Program
goptions reset=all border;
options nogstyle;
ods html close;
ods listing;
proc gchart data=sashelp.class;
pie age/discrete noheading value=none;
run;
quit;
libname gdevice0 "SAS-data-library";
proc gdevice nofs catalog=gdevice0.devices;
copy win from=sashelp.devices newname=mywin;
modify mywin
description="WIN with new color list"
colors=(black cx95c051 cxA359B2 cxD65259 cx69D6D2 cxFFB74F cx929cff);
quit;
goptions target=mywin;
proc gchart data=sashelp.class;
pie age/discrete noheading value=none;
run;
quit;
options gstyle;
ods html;
ods listing close;
Program Description
Set the graphics environment.
goptions reset=all border;
Turn styles off so that the device color list is used.
Close the HTML destination and open LISTING.The WIN device is valid only in the LISTING destination.
ods html close;
ods listing;
Generate the pie chart using the default WIN device.
proc gchart data=sashelp.class;
pie age/discrete noheading value=none;
run;
quit;
Assign the libref GDEVICE0. The
LIBNAME statement assigns the gdevice0 libref to the aggregate file
storage location that will contain the DEVICES catalog and the modified
WIN device entry.
libname gdevice0 "SAS-data-library";
Start the GDEVICE procedure. The
NOFS option causes GDEVICE to use program mode. The CATALOG= option
assigns GDEVICE0.DEVICES as the current device catalog. If the DEVICES
catalog does not already exist in the library, it is automatically
created.
proc gdevice nofs catalog=gdevice0.devices;
Copy the original device entry from SASHELP.DEVICES to
the current catalog. The NEWNAME= option
specifies a name for the copy of WIN that is placed in GDEVICE0.DEVICES.
The name of a catalog entry cannot exceed eight characters.
copy win from=sashelp.devices newname=mywin;
Modify the new entry. The
DESCRIPTION= option specifies a new device description that appears
in the catalog listing. The COLORS= option defines a new color list.
modify mywin
description="WIN with new color list"
colors=(black cx95c051 cxA359B2 cxD65259 cx69D6D2 cxFFB74F cx929cff);
Test the new device entry. The
TARGET= option specifies the new device. The GDEVICE0 libref is already
defined, so SAS/GRAPH searches GDEVICE0 for the specified device entry.
The GHART procedure generates a pie chart with the new color list.
goptions target=mywin;
proc gchart data=sashelp.class;
pie age/discrete noheading value=none;
run;
quit;
Turn styles back on, close the LISTING destination, and
reopen the HTML destination.
options gstyle;
ods html;
ods listing close;
Copyright © SAS Institute Inc. All rights reserved.