View previous topic :: View next topic
|
Author |
Message |
zerlina
New User
Joined: 27 Aug 2008 Posts: 7 Location: Pune
|
|
|
|
I am trying to generate an HTML file using SAS.
Code is as following -
%macro reprt1;
data _null_ ;
ODS HTML FILE="C:\sasout.htm";
put '<HTML>';
put '<HEAD>';
put '<BODY>';
put 'testing SAS - HTML output'
put '</BODY>';
put '</HEAD>';
put '</HTML>';
ODS HTML CLOSE;
run;
%mend reprt1;
%reprt1;
The HTML file is not getting created. Tried a lot of other options. Not working. Can someone pls help. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Which version of SAS are you using? What error messages does SAS generate when you attempt to create c:\sasout.htm? Are you sure there's no sasout.htm file being created -- or did it create one that has invalid HTML code in it? Have you read the SAS Output Delivery System User's Guide? If not, acquire a copy of it and start reading.
With all recent versions of SAS (from about 8.2 IIRC), all you have to say is
Code: |
ODS HTML FILE="..." ;
PROC PRINT;
ODSS HTML CLOSE; |
The tags are all automatically generated by SAS and putting them in your code, the way you show, is not only not required but will force HTML errors that would prevent the display of the HTML document. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Also, as posted your code has an error:
Code: |
put 'testing SAS - HTML output' |
does not have the trailing semicolon that it needs. |
|
Back to top |
|
|
zerlina
New User
Joined: 27 Aug 2008 Posts: 7 Location: Pune
|
|
|
|
Am using Version 8.2
It gives the following error -
"ERROR: Invalid file, C:\SASOUT.HTM."
Actually, i did a full search...it is creating an internet shortcut..
When i try to open it gives the following message -
"file:///C:/SASHTML.htm The specified path does not exist..
Not sure why this is happening...
ok u mean to say that i need to include only the required data in the code...and the tags will be automatically generated? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Okay, fixing the syntax errors, you should try this:
Code: |
data x;
testvar = 'testing SAS - HTML output';
output;
ODS HTML FILE="C:\sasout.htm";
proc print data=x;
run;
ODS HTML CLOSE;
|
The RUN; has to be before the ODS HTML CLOSE for it to generate the HTML correctly. I took out the tags you don't need -- because SAS will generate them for you. Also note that the ODS HTML FILE= format is used with PROC output -- not DATA steps. The syntax for using ODS HTML with DATA steps is very much different and you'll need to read the manual to see what is needed. |
|
Back to top |
|
|
zerlina
New User
Joined: 27 Aug 2008 Posts: 7 Location: Pune
|
|
|
|
Ok fine...
tried that..
now what is happening is...its showing the text 'testing SAS - HTML output' in the SASLIST..however in SASLOG its still giving the following error ..
"ERROR: Invalid file, C:\SASOUT.HTM.
ERROR: Invalid file, C:\SASOUT.HTM.
ERROR: Invalid file, C:\SASOUT.HTM.
WARNING: No body file. HTML output will not be created.
ERROR: Errors printed on page 1.
ERROR: Errors printed on page 1.
ERROR: Errors printed on page 1." and the file is not getting created..
Any idea what this implies... "No body file." |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Where are you running the SAS code? And post the exact code you're using now (in BBcode format). |
|
Back to top |
|
|
zerlina
New User
Joined: 27 Aug 2008 Posts: 7 Location: Pune
|
|
|
|
I'm running MainframeSAS...not PC SAS...
and i ran the exact code which u specified...The SAS has just that..its within a macro..as follows-
%macro reprt1;
data x;
testvar = 'testing SAS - HTML output';
output;
ODS HTML FILE="C:\sasout.htm";
proc print data=x;
run;
ODS HTML CLOSE;
%mend reprt1;
%reprt1; |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
1. Mainframe SAS requires you to build an output file on the mainframe. c:\sasout.htm has 2 characters not valid for mainframe file names (the colon and the backslash) and the first name level is 9 characters while the limit is 8. Change your name to something valid on your mainframe.
2. My code was written and tested using PC SAS since I assumed from the file name that you were using PC SAS. However, there is one big difference between my code and your code. Your code has a macro definition and invocation; mine does not. Your code is not what I asked you to test. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
After doing some research, I found TS-664 on the SAS web site which says
Quote: |
A DATA Stepper’s Introduction to ODS
As awareness of the Output Delivery System (ODS) becomes more widespread, I am frequently asked if existing DATA _NULL_ code can simply be wrapped in ODS statements to create ODS style output. While this is a straightforward question, the answer is not. |
You should read this paper for sure, and probably browse the ODS manual in more detail. There may be more on the SAS web site about ODS and DATA steps but that's what I found in a brief look. |
|
Back to top |
|
|
zerlina
New User
Joined: 27 Aug 2008 Posts: 7 Location: Pune
|
|
|
|
Ookk..
Fine..am reading through the paper...
Also, i want to know the difference between PC SAS and Mainframe SAS. Do u know of any good reference docs which i can go thru..
And...created the mainframe file..the HTML tags are all getting generated in that dataset...but now i dont know what to do next.. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
PC SAS and Mainframe SAS differ (1) in the platform they run on, (2) platform specifics (file allocation and assignment, numeric characteristics, and so forth), and (3) PC SAS uses a GUI interface that mainframe SAS doesn't support. Allowing for the platform differences, SAS code on a mainframe will run on a PC just fine. Check the SAS web site for their documentation -- they've got a manual for z/OS, one for Windows, and one for Unix boxes.
OK -- you've generated the HTML file. What were you planning on doing with the file? That tells you what to do next. Depending on your requirements, you may need to download the file to a server, download the file to a PC, or look at it directly on the mainframe (which requires knowing how your browser interacts with the mainframe). |
|
Back to top |
|
|
zerlina
New User
Joined: 27 Aug 2008 Posts: 7 Location: Pune
|
|
|
|
The task that i'm working on...requires a web page to be generated which contains some reports..the data for which is taken from the mainframe SAS datasets...the code for generating the same is also done in Mainframe SAS..
I have right now managed to generate a mainframe dataset that contains the HTML tags..bt now i want to use this to create a .html file in the windows operating system..can that be done...? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Do you have a server running Windows that you can transfer the html file to? Servers run different software than desktops, so you cannot (unless your site is extremely unusual) FTP the file from your mainframe to your desktop.
Contact your site support group and find out if IBM'S HTTP server is running on the mainframe. If so, have them establish a Unix System Services directory for your report files -- they may allocate an HFS or zFS file system and mount on a directory, depending on how big the reports are. Also have them update the HTTP web server configuration file to allow access to this directory (it needs a PASS directive to your directory). Change your SAS program to output to a file in that directory (which will be something like):
Code: |
ODS HTML FILE='/usr/zerlina/reports/043009.html'; |
Once this has been done, on your desktop you can enter into your browser
Code: |
http://<mainframe name or ip>/usr/zerlina/reports/043009.html |
and your report will show up on your desktop in the browser. |
|
Back to top |
|
|
zerlina
New User
Joined: 27 Aug 2008 Posts: 7 Location: Pune
|
|
|
|
i got PC SAS access...so now what i'm trying to do now is logon remotely to Mainframe from PC SAS...
Used the foll code-
%macro tcp;
%global mvs;
%let mvs = ibm3;
options remote = mvs;
filename rlink 'C:\Program Files\SAS Institute\SAS\V8\connect\saslink\logtso.scr';
%put NOTE: SAS/CONNECT configured for a Mainframe signon.;
SIGNON mvs;
%mend;
%tcp;
Getting the following error message -
ERROR: No data center network screen.
ERROR: A communication subsystem partner link setup request failure has occurred.
ERROR: Communication script processing aborted.
ERROR: Remote signon to MVS cancelled. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You will probably need to work with your site SAS support representative to resolve this. It sounds like a configuration issue between your SAS PC session and your mainframe; there are so many potential stumbling blocks (for example, SAS configuration options on the PC, SAS configuration options on the mainframe, TCP/IP configuration options on the mainframe, router firewall issues) that only your site support group is going to be able to help you. |
|
Back to top |
|
|
|