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

The image-file-spec argument in the DRAWIMAGE statement of the template language can be a relative local file path. But relative to what? I'm using SAS 9.3 TS1M0 on XP_PRO.

PG
1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

I believe you may have found a bug.  The GTL graph rendering is done using Java and we may not have told it the correct current work directory.  I have opened a defect to review this.  It seems "relative" is working off of the location provided in %USERPROFILE%.  The work around for you would be to put the image file there or use the fully qualified path.

View solution in original post

3 REPLIES 3
Jay54
Meteorite | Level 14

The file name is relative to your start folder (shown in the status line at the bottom of the SAS window).  If you start SAS in C:\Users\<userid>, and provide a file name without a path or url, then the image will be assumed to be in this folder.  In the example below, the file "saslogo.png" is expected to be in C:\Users\<userid>.  See attached output.

proc template;
  define statgraph image;
    begingraph / designwidth=400px designheight=300px;
      entrytitle "Regression Fit Plot"; 
        layout overlay; 
           modelband "myclm";
           scatterplot x=height y=weight / primary=true;
           regressionplot x=height y=weight / alpha=.01 clm="myclm"; 
           drawimage "saslogo.png" / x=95 y=5
               xspace=wallpercent yspace=wallpercent 
               anchor=bottomright; 
      endlayout; 
    endgraph;
  end;
run;

ods graphics / reset imagename="drawimage";
proc sgrender data=sashelp.class template=image; 
run;

drawimage.png
PGStats
Opal | Level 21

Thank you Sanjay, you confirm what I thought should happen. It works fine when supplied a full pathname but doesn’t with relative pathnames. The SAS program logged below produces two figures, the first one with no logo, the second one, using a full path, displays my logo :

1 x "cd C:\Documents and Settings\gagnonp\My Documents"

1 ! ;

2

3 proc template;

NOTE: Writing HTML Body file: sashtml.htm

4 define statgraph imageRelative;

5 begingraph / designwidth=400px designheight=300px;

6 entrytitle "Regression Fit Plot";

7 layout overlay;

8 modelband "myclm";

9 scatterplot x=height y=weight / primary=true;

10 regressionplot x=height y=weight / alpha=.01 clm="myclm";

11 drawimage "Environnement Canada Fr En.png" / x=95 y=5

12 xspace=wallpercent yspace=wallpercent

13 anchor=bottomright;

14 endlayout;

15 endgraph;

16 end;

NOTE: Overwriting existing template/link: imageRelative

NOTE: STATGRAPH 'imageRelative' has been saved to: SASUSER.TEMPLAT

17 define statgraph imageFull;

18 begingraph / designwidth=400px designheight=300px;

19 entrytitle "Regression Fit Plot";

20 layout overlay;

21 modelband "myclm";

22 scatterplot x=height y=weight / primary=true;

23 regressionplot x=height y=weight / alpha=.01 clm="myclm";

24 drawimage "C:\Documents and Settings\gagnonp\My

24 ! Documents\Environnement Canada Fr En.png" /

25 x=95 y=5

26 xspace=wallpercent yspace=wallpercent

27 anchor=bottomright;

28 endlayout;

29 endgraph;

30 end;

NOTE: Overwriting existing template/link: imageFull

NOTE: STATGRAPH 'imageFull' has been saved to: SASUSER.TEMPLAT

31 run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

real time 1.65 seconds

cpu time 0.57 seconds

32

33 ods graphics / reset imagename="drawRelative";

34 proc sgrender data=sashelp.class template=imageRelative;

35 run;

WARNING: IMAGE=Environnement Canada Fr En.png n'est pas valide. Fichier introuvable.

WARNING: IMAGE=Environnement Canada Fr En.png n'est pas valide.

NOTE: There were 19 observations read from the data set SASHELP.CLASS.

NOTE: PROCEDURE SGRENDER used (Total process time):

real time 1.62 seconds

cpu time 0.36 seconds

36 ods graphics / reset imagename="drawFull";

37 proc sgrender data=sashelp.class template=imageFull;

38 run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.

NOTE: PROCEDURE SGRENDER used (Total process time):

real time 0.46 seconds

cpu time 0.06 seconds

PG
Jay54
Meteorite | Level 14

I believe you may have found a bug.  The GTL graph rendering is done using Java and we may not have told it the correct current work directory.  I have opened a defect to review this.  It seems "relative" is working off of the location provided in %USERPROFILE%.  The work around for you would be to put the image file there or use the fully qualified path.

sas-innovate-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 875 views
  • 3 likes
  • 2 in conversation