The SAS Output Delivery System and reporting techniques

ODS, proc template style

Reply
Occasional Contributor
Posts: 10

ODS, proc template style

I am trying to create and use a style with the following ODS in an scl web app. When I use the following code I get the error message that style cannot be found. The log shows the style is being saved. Can you please explain where I am going wrong?

submit continue;
proc template;
define style dashboard / store=styles;
parent=styles.minimal;
style header_blue_center /
background = cx7ACAFF
font = ("Arial",8pt,Bold)
foreground = cx000000
just = C
frame = box;
end;
run;
quit;

ods escapechar = '~';
options nonumber;
%let RV=%sysfunc(appsrv_header(Content-type, application/vnd.ms-excel));
%let RV=%sysfunc(appsrv_header(Content-disposition, %str(attachment; filename=temp.xls)));
ods html body=_webout style=styles.dashboard;
proc report data=work.exceldata;
define short / display "Short Study Number"
style(column)=header_blue_center
style(header)=header_blue_center;
run;
endsubmit;
SAS Employee
Posts: 174

Re: ODS, proc template style

Try this:
[pre]
define style styles.dashboard;
[/pre]
instead of:
[pre]
define style dashboard / store=styles;
[/pre]

-- David Kelley, SAS
Occasional Contributor
Posts: 10

Re: ODS, proc template style

Posted in reply to David_SAS
Thanks David. When I try that syntax I get this error.

ERROR: Template 'Styles.Dashboard' was unable to write to template store!
SAS Employee
Posts: 174

Re: ODS, proc template style

I believe that you need to check your ODS PATH settings. ODS PATH needs to define a writable template itemstore so that PROC TEMPLATE can store your template definition.

Typically the first itemstore in the ODS PATH is SASUSER.TEMPLAT, and typically it's writable.

You can check the ODS PATH by executing:
[pre]
ods path show;
[/pre]
-- David Kelley, SAS
SAS Super FREQ
Posts: 8,862

Re: ODS, proc template style

Hi:
Just a few comments to add to what David said. Are you using either SAS/IntrNet and an SCL program or a SAS Stored Process (calling an SCL program)?

If so, you may find that your updated style template needs to be written to an item store or template store that "lives" on a server that is accessible to your platform configuration (SAS/IntrNet Application Server or Stored Process Server). (In other words, you cannot write the updated template to your personal C: drive.)

Next, if you are trying to open your result file with Excel (as indicated by your appsrv_header function), you may find that ODS HTML does not work as well as ODS HTML3. It turns out that ODS HTML in SAS 9 creates HTML 4.01 compliant tags and Excel is much happier with HTML 3.2 compliant tags. You may want to invoke ODS HTML3 instead of ODS HTML in your invocation code.

Finally to reiterate what David said, you need to control your new template location with a libname and an ODS PATH statement. Something like this:
[pre]
libname mytemp 'server-path-location-for-changed-templates';

ods path mytemp.templat(update)
sasuser.templat(update)
sashelp.tmplmst(read);

proc template;
define style styles.dashboard / store=mytemp.templat;
...
end;
run;
[/pre]

With this code, a folder or directory named "styles" will be created in the item store "mytemp.templat". Inside the "styles" folder, you will be creating a new style template called "dashboard". However, you will only want to write to mytemp.templat when you are creating or updating your new template. (Probably 1 time) Most of the time, when running jobs, you will just need to POINT to the new item store on the server like this:

[pre]
libname mytemp 'server-path-location-for-changed-templates';

ods path mytemp.templat(read)
sasuser.templat(read)
sashelp.tmplmst(read);

ods escapechar = '~';
options nonumber;
%let RV=%sysfunc(appsrv_header(Content-type, application/vnd.ms-excel));
%let RV=%sysfunc(appsrv_header(Content-disposition, %str(attachment; filename=temp.xls)));

ods html3 file=_webout style=styles.dashboard;
...more code...
ods html3 close;
[/pre]


cynthia
Occasional Contributor
Posts: 10

Re: ODS, proc template style

Posted in reply to Cynthia_sas
You guys rock! Your advice worked like a charm. I utilized the save library and therefore did not need the libname statement. Yes, I am using SAS/IntrNet and an SCL program. Your suggestion regarding HTML3 also improved performance.

Thank you!
Smitty
Ask a Question
Discussion stats
  • 5 replies
  • 228 views
  • 0 likes
  • 3 in conversation