Help using Base SAS procedures

How do I assign HTML to be saved to my desired directory ?

Reply
Frequent Contributor
Posts: 78

How do I assign HTML to be saved to my desired directory ?

Hi all,

I am using SAS 9.2 at the moment and I understand that under Tools > Options > Preference > Results > Create HTML shows the directory of where my html page is going to be saved whenever i generate a html.

Is there any script that I can write that will automatically direct my html page to be saved to my desired directory without having to manually go to Tools > Options to change it every time I run the script ?

Hope someone can help.

Cheers!
SAS Super FREQ
Posts: 8,868

Re: How do I assign HTML to be saved to my desired directory ?

Hi:
I'm not sure what you mean by a "script". However, with SAS program code, you can absolutely direct your HTML output to a specific directory location.

cynthia
[pre]
ods html file='c:\temp\myfile1.html';
...sas code to generate output ....
ods html close;

OR

ods html path='c:\temp' (url=none)
gpath='c:\temp' (url=none)
file='myfile2.html';
....sas code and sas/graph code to generate output...
ods html close;
[/pre]

The first method is what you would use to create simple tabular output (no graphs) and your output would go to the fully qualified path name that is shown in the FILE= option.

The second method is the recommended method to use when you are going to create graphic output ... by using PATH= and GPATH=, you guarantee that any tabular and graphic output will be written to the desired location (in this case, the same location, c:\temp) and the URL=NONE option informs ODS HTML to build a relative anchor tag for any HREF information that it might use (such as in an <IMG> tag).

I find that, for me, this is the preferred method for controlling the location of all ODS output, rather than the Tools-->Options method because it gives me the most control over my program output.

cynthia
Frequent Contributor
Posts: 78

Re: How do I assign HTML to be saved to my desired directory ?

Posted in reply to Cynthia_sas
Hi Cynthia,

I have used your method however it came up with this error...

ERROR: Physical file does not exist, 'c:\temp\report.html'.
WARNING: No body file. HTML output will not be created.

Do you know why ?

Cheers.
Frequent Contributor
Posts: 78

Re: How do I assign HTML to be saved to my desired directory ?

Posted in reply to Cynthia_sas
Hey Cynthia!

That's okay. I got it all sorted out!

Thank you so much for your help!

Cheers.
Contributor
Posts: 61

Re: How do I assign HTML to be saved to my desired directory ?

I was following your discussion. I have the same warning message. How did you finally solve the problem?
SAS Super FREQ
Posts: 8,868

Re: How do I assign HTML to be saved to my desired directory ?

Hi:
I am guessing that the issue was that "C:\temp" was not in existence at the time the program was run. ODS HTML will not create a directory. The directory that you write to using either file= or path= must already be created and you must have operating system level write access to the directory.

So, for example, if you have:
[pre]
ODS HTML file='c:\reports\fred\myfile.html';
[/pre]

And c:\reports\fred directory does not exist, you will get an error message. Or, if the directory exists, but you do not have write access to c:\reports\fred directory, you will also get an error message.

cynthia
Valued Guide
Posts: 2,177

Re: How do I assign HTML to be saved to my desired directory ?

Posted in reply to Cynthia_sas
the windows platform may not have a c:\temp folder, but does use an environment variable TEMP pointing to a corresponding location usually within the users profile.

SAS refers to windows environment variables through the %sysget() function, or with an ! prefix, like may be seen in SAS configuration files, with lines like
-WORK "!TEMP\SAS Temporary Files"
In our SAS code we can use similar syntax to write to TEMP using code like
ODS html file='!temp\myfile1.html';
Ask a Question
Discussion stats
  • 6 replies
  • 167 views
  • 0 likes
  • 4 in conversation