Friday, July 27, 2007

SAS plus


The following is the complete SAS code to generate the animated GIF and an HTML file that references it. You should notice the following:
• The GSFNAME= option of the GOPTIONS statement specifies the name of the GIF to be created. In this example, the value of GSFNAME is specified in an associated FILENAME statement. If you want to run this example, then change the value of the FILENAME statement to something that makes sense for you.
• The following statement
goptions gsfmode=append;
is included before the second invocation of PROC GCHART so that the output is appended to the same GIF file.
• A FILE statement specifies the complete path and file name of the HTML file to be created by the PUT statements. If you want to run this example, then change the value to something that makes sense for you
data prdsummary;
input Year Quarter Country $ Product $ Actual dollar10.2;
label Actual = 'Actual Sales';
format Actual dollar11.;
datalines;
1993 1 CANADA BED $4,337.00
1993 1 CANADA CHAIR $5,115.00
1993 1 CANADA DESK $6,644.00
1993 1 GERMANY BED $5,026.00
1993 1 GERMANY CHAIR $6,276.00
1993 1 GERMANY DESK $4,330.00
1993 2 CANADA BED $2,437.00
1993 2 CANADA CHAIR $3,115.00
1993 2 CANADA DESK $5,654.00
1993 2 GERMANY BED $3,026.00
1993 2 GERMANY CHAIR $2,276.00
1993 2 GERMANY DESK $3,320.00
1993 3 CANADA BED $6,337.00
1993 3 CANADA CHAIR $7,145.00
1993 3 CANADA DESK $7,614.00
1993 3 GERMANY BED $5,026.00
1993 3 GERMANY CHAIR $3,276.00
1993 3 GERMANY DESK $6,340.00
1993 4 CANADA BED $9,337.00
1993 4 CANADA CHAIR $2,115.00
1993 4 CANADA DESK $3,646.00
1993 4 GERMANY BED $6,026.00
1993 4 GERMANY CHAIR $7,276.00
1993 4 GERMANY DESK $8,350.00
1994 1 CANADA BED $3,327.00
1994 1 CANADA CHAIR $5,345.00
1994 1 CANADA DESK $7,624.00
1994 1 GERMANY BED $4,026.00
1994 1 GERMANY CHAIR $3,276.00
1994 1 GERMANY DESK $3,340.00
1994 2 CANADA BED $5,356.00
1994 2 CANADA CHAIR $3,115.00
1994 2 CANADA DESK $7,623.00
1994 2 GERMANY BED $8,026.00
1994 2 GERMANY CHAIR $5,276.00
1994 2 GERMANY DESK $7,321.00
1994 3 CANADA BED $4,321.00
1994 3 CANADA CHAIR $3,115.00
1994 3 CANADA DESK $5,658.00
1994 3 GERMANY BED $6,026.00
1994 3 GERMANY CHAIR $5,276.00
1994 3 GERMANY DESK $6,398.00
1994 4 CANADA BED $5,357.00
1994 4 CANADA CHAIR $4,166.00
1994 4 CANADA DESK $7,662.00
1994 4 GERMANY BED $4,026.00
1994 4 GERMANY CHAIR $5,246.00
1994 4 GERMANY DESK $3,329.00
;
/* delete previously created gsegs before creating new ones */
/* (SAS creates gsegs before creating gifs from them */
proc greplay igout=work.gseg nofs;
delete _all_;
/* could also specify: delete _1993, _19931, etc. */
run; quit;



/* use filename to specify output folder for gif files */
filename myimages 'u:\public_html\Web_output\gifanim.gif';
goptions reset=all device=gifanim gsfname=myimages
gsfmode=replace /* not necessary when using "BY" */
delay=150 /* set delay between images */
border
ftext="Helvetica" ftitle="Helvetica";

title1 '1993 Sales';
proc gchart data=prdsummary(where=(year=1993));
hbar3d country / sumvar=actual subgroup=product sum
shape=hexagon caxis=black cframe=CXb0c1f4;
by quarter;
run;
quit;
goptions gsfmode=append;
title1 '1994 Sales';
proc gchart data=prdsummary(where=(year=1994));
hbar3d country / sumvar=actual subgroup=product sum
shape=hexagon caxis=black cframe=CXb0c1f4;
by quarter;
run;
quit;

No comments: