BookmarkSubscribeRSS Feed
Smitty
Fluorite | Level 6
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;
5 REPLIES 5
David_SAS
SAS Employee
Try this:
[pre]
define style styles.dashboard;
[/pre]
instead of:
[pre]
define style dashboard / store=styles;
[/pre]

-- David Kelley, SAS
Smitty
Fluorite | Level 6
Thanks David. When I try that syntax I get this error.

ERROR: Template 'Styles.Dashboard' was unable to write to template store!
David_SAS
SAS Employee
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
Cynthia_sas
SAS Super FREQ
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
Smitty
Fluorite | Level 6
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

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
  • 5 replies
  • 1087 views
  • 0 likes
  • 3 in conversation