BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lingcx
Obsidian | Level 7

I'm creating plots from proc univariate or proc sgplot. It seems that the system always automatically adds a "1" at the end of my imagename. In the example below, it will give me a plot names "abcde1". 

 

ods graphics on / reset width=8in height=6in imagename="abcde";
proc univariate data=Stats;
var x;
histogram / midpoints=10 to 100 by 10;
run;

 

Any clue how to get rid of this? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
DWilson
Pyrite | Level 9
Here you go. Code with results. HTML is the only thing selected under EG results formats.
Specifying reset=index doesn't change the behavior. If I uncheck HTML in the SAS EG results viewer page and run the code below then it does not add a number to the end of abcde in the name of the .png file.


ods html path="/rtpnfil02/rtpnfil02_vol6/CSDS/CENTER/dhw/Test/" gpath="/rtpnfil02/rtpnfil02_vol6/CSDS/CENTER/dhw/Test";
ods graphics on / reset width=8in height=6in imagename="abcde" ;
proc univariate data=sashelp.class;
var weight;
histogram / midpoints=10 to 100 by 10;
run;
ods html close;

SAS_filename.jpg

View solution in original post

12 REPLIES 12
ChrisNZ
Tourmaline | Level 20

I'm creating plots from proc univariate or proc sgplot. It seems that the system always automatically adds a "1" at the end of my imagename. In the example below, it will give me a plot names "abcde1". 

 

ods graphics on / reset width=8in height=6in imagename="abcde";
proc univariate data=Stats;
var x;
histogram / midpoints=10 to 100 by 10;
run;

 

Any clue how to get rid of this? Thanks!

I don't see this. When does it happen for you?

ods html file="%sysfunc(pathname(WORK))\abcde.htm"      ;
ods graphics on / reset width=8in height=6in imagename="abcde";
proc univariate data=sashelp.class;
var weight;
histogram / midpoints=10 to 100 by 10;
run;
ods html close;

Capture.PNG

 

 

 

 

 

lingcx
Obsidian | Level 7

It happened repeatedly. I don't have that "ods html" envelope (below) outside of ods graphics, because I only need the picture file but not the html. Could this be why?

 

ods html file="%sysfunc(pathname(WORK))\abcde.htm"      ;
...
ods html close;

 

lingcx
Obsidian | Level 7

Thanks for your reply.

 

Like "abcde1.png" in my folder. Really weird.

DWilson
Pyrite | Level 9

Ok, I think I've figured out the issue following this post:

https://communities.sas.com/t5/Graphics-Programming/ODS-Graphics-Index-Counter-Resets-to-1/td-p/2089...

 

But their solution did not work. In other words, adding ODS HTML close (or ODS LISTING CLOSE) did not work when I was trying a different type of output. What I had to go was go into the EG settings (Tools->Option>-Results) and uncheck HTML. After doing that, the example code posted above, modified to use a listing output, produced an image name with no index attached.

 

What's happening is that there are two ODS outputs open; listing and html and that's why the index is showing up. Closing the HTML output leaves one output and no index appears in your image name.

 

Ksharp
Super User

Try 

ods graphics on / reset=index

DWilson
Pyrite | Level 9

That didn't work for me. I have the same issue as the original poster. The issue turns out to be, at least for me using SAS EG, that there is a default HTML destination opened in SAS EG, opened even if you don't specify ODS HTML; in your code, and I had to turn off the default HTML results destination in SAS EG before I could get the  index to be suppressed.


@Ksharp wrote:

Try 

ods graphics on / reset=index


 

Reeza
Super User
Can you show a screenshot of the folder with the files in them with the names please?

I've seen this happen in OneDrive and Google Drive because of versioning by the way. It's quick and hard to notice but it does happen.
DWilson
Pyrite | Level 9
Here you go. Code with results. HTML is the only thing selected under EG results formats.
Specifying reset=index doesn't change the behavior. If I uncheck HTML in the SAS EG results viewer page and run the code below then it does not add a number to the end of abcde in the name of the .png file.


ods html path="/rtpnfil02/rtpnfil02_vol6/CSDS/CENTER/dhw/Test/" gpath="/rtpnfil02/rtpnfil02_vol6/CSDS/CENTER/dhw/Test";
ods graphics on / reset width=8in height=6in imagename="abcde" ;
proc univariate data=sashelp.class;
var weight;
histogram / midpoints=10 to 100 by 10;
run;
ods html close;

SAS_filename.jpg

lingcx
Obsidian | Level 7

Interesting.

 

reset=INDEX solved my problem. Thanks!!

delonay
Calcite | Level 5

I've dealt with the same issue for various projects and I FINALLY figured out what I was doing wrong.

 

This will NOT work:

ODS GRAPHICS / reset=index IMAGENAME="my_map" IMAGEFMT=png NOBORDER;
ODS HTML PATH="X:\abc\def" (URL=none);
PROC SGMAP MAPDATA=data1 MAPRESPDATA=data2 NOAUTOLEGEND; 
  ESRIMAP URL='http://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Light_Gray_Base';
  CHOROMAP abc / MAPID=def ID=def DISCRETE;
RUN;

But this DOES work:

ODS HTML PATH="X:\abc\def" (URL=none);
ODS GRAPHICS / reset=index IMAGENAME="my_map" IMAGEFMT=png NOBORDER;
PROC SGMAP MAPDATA=data1 MAPRESPDATA=data2 NOAUTOLEGEND; 
  ESRIMAP URL='http://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Light_Gray_Base';
  CHOROMAP abc / MAPID=def ID=def DISCRETE;
RUN;

Note the order - as long as the ODS GRAPHICS statement is listed below/after the ODS HTML statement, then this works. If it's flipped like I showed in the first code snippet, the code will create a file called 'my_map1.png'.

SigmaGo
Calcite | Level 5
Thanks for your post. It solved my problem.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 12 replies
  • 3728 views
  • 8 likes
  • 7 in conversation