BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am using both GPLOT and GMAP to create *.gif files in SAS. I would like to control the naming conventions for these files and not be stuck with the default name (e.g. gplot14. gif, gmap5.gif) because I have trouble identifying the correct graphic when I create large numbers of these files.

Two items would be helpful.

First, how do I change the default filename body to something other than gmap or gplot? I would like to identify the contents with meaningful names.

Second, how do I restart the numbering scheme? When I am debugging my programs, the numbers keep incrementing even though I delete the files. I would like to be able to reset the numbers to start over. At this point, I can only reset the number by exiting PC SAS.

Thanks in advance.
2 REPLIES 2
GraphGuy
Meteorite | Level 14
You can control the gif/png file name of traditional SAS/Graph procs by using the "name=" option in the proc. This controls the name of the grseg, and that name is also used as the name of the gif/png file.

In v9.2, you can use the value of the "by" variable as part of the name, and v9.2 also supports >8 characters for the name of the gif/png specified here! 🙂

If deleting all the grsegs is not re-setting the name auto-increment, I would suggest starting a new SAS session each time - I always run my SAS jobs in batch, so that each time it is a fresh invocation, and therefore I don't have to worry about deleting grsegs to reset the name auto-incrementing, etc. (ymmv!)

Below is a v9.2 example that demonstrates using the by-variable to control the png file name:


%let name=map066;
filename odsout '.';

data my_data;
st='NC'; output;
st='SC'; output;
st='VA'; output;
run;

data my_map; set maps.us;
st=fipstate(state);
run;


GOPTIONS DEVICE=png;
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm";

title "This state is #byval(st)";

proc gmap map=my_map data=my_data all;
by st;
id st;
choro st / levels=1
coutline=gray nolegend
des="" name="&name._#byval(st)";
run;

quit;
ODS HTML CLOSE;
ODS LISTING;
deleted_user
Not applicable
Thanks so much for your help. I was able to make significant progress in resolving my problems.

One of the things that I learned along the way was how to clean up after creating graphs so that the numbering schema did not plague my code. The process involved PROC CATALOG:

PROC CATALOG CAT=WORK.Gseg ET=Grseg;
DELETE &fname1 &fname2;
QUIT;

PROC CATALOG CAT=WORK.Html ET=Grseg;
DELETE &fname1 &fname2;
QUIT;

The files that I created are deleted within a macro:

X "DEL &_dir\&fname1..htm"; X "DEL &_dir\&fname2..htm";
X "DEL &_dir\&fname1..gif"; X "DEL &_dir\&fname2..gif";

The macro itself iterates through the list of files.

Stephen

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1188 views
  • 0 likes
  • 2 in conversation