BookmarkSubscribeRSS Feed
Yennie
Calcite | Level 5
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!
6 REPLIES 6
Cynthia_sas
SAS Super FREQ
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
Yennie
Calcite | Level 5
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.
Yennie
Calcite | Level 5
Hey Cynthia!

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

Thank you so much for your help!

Cheers.
chandler
Fluorite | Level 6
I was following your discussion. I have the same warning message. How did you finally solve the problem?
Cynthia_sas
SAS Super FREQ
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
Peter_C
Rhodochrosite | Level 12
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';

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 1028 views
  • 0 likes
  • 4 in conversation