Data visualization with SAS programming

Base path for DRAWIMAGE in Template Language

Accepted Solution Solved
Reply
Respected Advisor
Posts: 4,816
Accepted Solution

Base path for DRAWIMAGE in Template Language

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

Accepted Solutions
Solution
‎08-30-2011 05:50 PM
SAS Super FREQ
Posts: 1,141

Base path for DRAWIMAGE in Template Language

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


All Replies
SAS Super FREQ
Posts: 1,141

Base path for DRAWIMAGE in Template Language

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
Respected Advisor
Posts: 4,816

Base path for DRAWIMAGE in Template Language

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
Solution
‎08-30-2011 05:50 PM
SAS Super FREQ
Posts: 1,141

Base path for DRAWIMAGE in Template Language

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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