BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi. There's a "little" problem i can't solve.

I have to create a user-defined HTML-Output (e.g. for an Input-User-Interface).
At first i tried a code like these simplyfied:

data _null_;
file print no_top_matter;
put '';
put '';
put 'test';
put '';
put '';
put test;
put '';
put '';
run;

But it didn't work. The ODS-Output also creates a HTML-Structure an the HTML-Code from the Data-Step is inserted in these structure (exactly it's inserted into an Table in the ODS-HTML-Structure).
If i use a Filename-Statement to save the Html-File i became exactly what i need; only the Html-Code i've written in my Data-Step. But later the HTML-Code should be created in a Stored Process and the HTML-Output shoud be streamed to the Browser (via ODS i suppose).

Is there any way to directly output the HTML-Code from the Data-Step without the ODS-HTML-Structure?
4 REPLIES 4
deleted_user
Not applicable
See if this code of mine can help you.
Pay attention to the ODS statements and read the documentation about the ODS markup options I'm using
[pre]
%macro build_html(host);

%let configuration = &host.__configuration.html;
%let buttons = &host.__buttons.html;
%let graphs = &host.__graphs.html;

ods listing close;

filename body "&base_dir\&host..html";
ods chtml body = body (no_bottom_matter);
ods chtml close;

filename body "&base_dir\&host..html" mod;

data _null_;
file body;
put '';
put " ";
put " ";
put " ";
put "";
run;

ods chtml body=body (no_top_matter);
ods chtml close;
filename body clear;

filename body "&base_dir\&configuration";
ods htmlcss body = body (no_bottom_matter)
stylesheet = styles;
ods htmlcss close;

filename body "&base_dir\&configuration" mod;

data _null_;
set static.system_configuration;
where node_name = "&host";
by node_name;
file body;
if last.node_name;

put '';
put ' ';
put ' ';
put '
Server Name: ' node_name $;
put '
 ';
put '
data as of ' date;
put '
Vendor = ' cpu_vendor $;
put '
model = ' system_model $;
if number_processors = 1 then
put '
' number_processors 2. ' processor' ;
else
put '
' number_processors 2. ' processors' ;
put '
';
run;

ods htmlcss body=body (no_top_matter);
ods htmlcss close;
filename body clear;

filename body "&base_dir\&graphs";
ods htmlcss body = body (no_bottom_matter)
stylesheet = styles;
ods htmlcss close;

filename body "&base_dir\&graphs" mod;

data _null_;
file body;
if fileexist("&base_dir\&host")
then do;
fileref="dir";
rc = filename(fileref,"&base_dir\&host");
did = dopen(fileref);
files = dnum(did);
columns = ceilz(sqrt(files));
rows = roundz(sqrt(files));

put '';
put '';
put '';
put '
';
rc = dclose(did);
rc = filename(fileref);
end;
run;

ods htmlcss body=body (no_top_matter);
ods htmlcss close;
filename body clear;

filename body "&base_dir\&buttons";
ods htmlcss body = body (no_bottom_matter)
stylesheet = styles;
ods htmlcss close;

filename body "&base_dir\&buttons" mod;

data _null_;
file body;
if fileexist("&base_dir\&host")
then do;
fileref="dir";
rc = filename(fileref,"&base_dir\&host");
did = dopen(fileref);
files = dnum(did);
columns = files+1;
width = 'width='||trim(left(put(floor(100/columns),3.)))||'%';
put '';
put ' ';
put '
All Charts";
do i=1 to files;
member = dread(did,i);
pointer = scan(member,1,".");
put '
" pointer $ '';
end;
put '
';
rc = dclose(did);
rc = filename(fileref);
end;
run;

ods htmlcss body=body (no_top_matter);
ods htmlcss close;
filename body clear;

ods listing;

%mend;
[/pre]
deleted_user
Not applicable
That's a very interesting example.
But my problem is, that i don't need a storaged file.
The HTML-Code should be streamed by an Stored Process; like using the "file print" statement without creating the ODS HTML-Structure.
deleted_user
Not applicable
Did you bother to read the documentation for ODS? Specifically ODS CHTML? and what about the body options I am using?

Perhaps you should read about SAS's web development tools/products.

The main point here, is READ! That's how we all learn to do this stuff, by reading and then trying.
Cynthia_sas
SAS Super FREQ
Hi:
When you move into the world of stored processes, you have to be very careful with your stored process. Not all of the SAS Enterprise Intelligence Platform clients -receive- HTML output. For example, the general method to create streaming output is to use:
[pre]
*ProcessBody;
%stpbegin;
...sas code...
%stpend;
[/pre]

Which will tailor the output "type" appropriately for the client app. For example, the above stored process code would create varying output like this for the different client apps:
[pre]
Client Receives
EG = HTML (unless changed at the client app Options menu)
PPT = SASReport XML (only type supported by PPT)
Word = SASReport XML (unless user picks RTF or HTML as option)
Excel = SASReport XML (unless user picks CSV or HTML as optio)
WRS = SASReport XML (only type supported by WRS)
Portal = HTML (unless coded as different type, like RTF or PDF by programmer)
Custom = same as portal
[/pre]

By custom, in the above, I mean a custom client app that you might develop yourself and submit the SP using your own front end application (such as Java or .NET or HTML front end).

The issue of writing your own HTML with PUT statements is something that SAS/IntrNet programmers used to do. You are correct in that you can no longer use the FILE PRINT fileref. Instead you must use the _WEBOUT fileref.

However, it is NOT recommended that you use PUT statements to _WEBOUT inside a stored process. This recommendation is documented in this location
http://support.sas.com/rnd/itech/doc9/dev_guide/stprocess/inet2stp.html
(which is talking about how to convert your SAS/IntrNet programs to be stored processes). This does not come up for most people because with "new" applications, they would use this technique to write "plain" CHTML or PHTML:

[pre]
*ProcessBody;

%let _odsdest=chtml;
%stpbegin;
...sas code...
%stpend;
[/pre]

OR

[pre]
*ProcessBody;

%let _odsdest=phtml;
%stpbegin;
...sas code...
%stpend;
[/pre]

and, if you wrote your own custom tagset template and stored it on the server, then you could do this:
[pre]
*ProcessBody;

%let _odsdest=tagsets.mycustomhtml;
%stpbegin;
...sas code...
%stpend;
[/pre]

All of the above assume that you are using a SAS stored process to generate output from some SAS process or procedure -- and that there will be output that needs the SAS ODS structure for the tabular or graph output. Your HTML with PUT statements is more like a test page -- it's not executing any code.

If you need help with your Stored Process development, your best bet is to read the stored process documentation and/or look at some of these SGF papers and/or work with Tech Support.

http://support.sas.com/rnd/itech/doc9/dev_guide/stprocess/index.html
http://www2.sas.com/proceedings/forum2008/024-2008.pdf
http://www2.sas.com/proceedings/forum2007/218-2007.pdf
http://www2.sas.com/proceedings/forum2008/393-2008.pdf
cynthia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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