The SAS Output Delivery System and reporting techniques

TEMPLATE TAGSET EVENT INITIALIZE

Reply
New Contributor
Posts: 4

TEMPLATE TAGSET EVENT INITIALIZE

Hi guys,
Running SAS 9.1.3.
Trying to create a set of customized tagsets.
I am facing a strange behaviour with the event initialize.
When using the proc print, I can see that the initialize event is ran several times with the side effect that the memory variables populated during the tagset execution are being cancelled, if I am using the XML engine in data step I don't have the problem.

Here is the code, if you have any idea about it is welcome otherwise I will ask a defect id with tech support.

ODS PATH work.TMPBIT(UPDATE) SASHELP.TMPLMST(read) ;

proc template;
define tagset tagsets.test2 ;
notes "Keinavo TAGSET ";
indent = 3;
map = '<>&"''';
mapsub = '/</>/&/"/'/';

define event initialize ;
start:
eval $testvar 4;
put "====initialize:start:====" nl;
putvars mem _name_ ": " _value_ nl;

put "===================" nl;

break ;
end ;
define event test ;
eval $testvar 3;
put "test" CR ;
break ;
end ;

define event doc;
start:
trigger test ;
break;
finish:
break;
end;

define event doc_head;
start:
break;
finish:
break;
end;

define event doc_body;
start:
put "******doc_body:start:*********" nl;
putvars mem _name_ ": " _value_ nl;
put "*******************" nl;
break;
finish:
put "******doc_body:finish:*******" nl;
putvars mem _name_ ": " _value_ nl;
put "*******************" nl;
break;
end;

define event data;
start:
break / if !cmp(SECTION, "body");
break / if cmp(XMLMETADATA, "ONLY");
eval $testvar 3 ;
set $myvalues[] _value_ ;
break;
finish:
break / if !cmp(SECTION, "body");
break / if cmp(XMLMETADATA, "ONLY");
break;
end;

define event table_body;
start:
trigger test ;
break;
finish:
put "******table_body:finish:********" nl;
putvars mem _name_ ": " _value_ nl;
put "*******************" nl;
break;
end;
end ;
run ;

filename _webout "C:\work\engine92.xml";

libname _webout xml xmltype=GENERIC tagset=tagsets.test2 ;

options OBS=10 ;

proc copy in=SASHELP out=_webout ;
select CLASS ;
run;
/*
data _webout.class ;
set sashelp.class ;
run ; */
SAS Super FREQ
Posts: 8,745

Re: TEMPLATE TAGSET EVENT INITIALIZE

Hi:
You may want to work with Tech Support on this issue. The various events, such as TABLE_BODY and DATA and DOC_BODY and DOC_HEAD, etc are triggered by SAS and when the event is sent to the open destinations it is the destination that handles the DEFINE EVENT block.

I would expect PROC PRINT to definitely trigger the different events than the events triggered by the LIBNAME engine. Therefore, I would EXPECT you to get different results when you used PROC PRINT with this tagset template versus when you used the LIBNAME engine. So I'm confused -- do you want a TAGSET template to use with ODS or to use with the LIBNAME engine???

In my paper for PharmaSUG a few years ago, I showed the use of a "custom" tagset template that would work for either the LIBNAME engine or the SAS procedures. I got the "custom" template from the developers and at one time, they were talking about rollling some version of the custom tagset out in the item store, but that was NOT true in SAS 9.1.3 -- you needed to get a copy of the custom tagset template in order to replicate the programs in my paper:
http://www.lexjansen.com/pharmasug/2006/technicaltechniques/tt24.pdf

In addition, when you are using SAS 9.1.3, you do not have access to the 9.2 LIBNAME XML engine (which would be specified by XML92 in the LIBNAME statement). (Wondering why you name your outputfile engine92.xml -- when you have SAS 9.1.3??)
http://support.sas.com/documentation/cdl/en/engxml/62845/HTML/default/viewer.htm#/documentation/cdl/...

Also, you use _WEBOUT as the LIBREF and FILEREF and, generally, speaking, this is a bad idea because in some configurations (such as SAS/IntrNet and the BI Platform) _WEBOUT is a reserved file reference for capturing output.

Perhaps you could explain a bit about what you want your TAGSET template to do and whether you want to use it with the LIBNAME engine or ODS. Also, whether you have used the EVENT_MAP tagset to trace what events your procedure of interest might be using. An example of the EVENT_MAP tagset is shown below. If you examing the 2 output files, you will see the "map" of all the events that were triggered by each SAS process.

In order to learn about the events that are triggered when you use the SAS XML Libname Engine (SXLE) in SAS 9.1.3, you have to look at the tagset templates that all start with "SAS" in the template item store. These tagset templates, such as SASIO, SASXMOG, etc will use DIFFERENT events than the events used by the procedures when output is routed to ODS. So your final tagset template will need to be tailored accordingly.

cynthia
[pre]
ods tagsets.event_map file='ev_print.txt';

proc print data=sashelp.class(obs=3);
title 'Event Map for Proc Print';
run;

ods tagsets.event_map close;


ods tagsets.event_map file='c:\temp\ev_frq.txt';

proc freq data=sashelp.class;
titles 'Event Map for Proc Freq';
tables age;
run;
ods tagsets.event_map close;
[/pre]
New Contributor
Posts: 4

Re: TEMPLATE TAGSET EVENT INITIALIZE

Hi cynthia,

Thanks for your feedback.

Here are my comments.
I am using _WEBOUT as a filename for testing because the tagsets I am creating aim to be used in a STP context.
The doc has been tested in SAS913 and in SAS92.
I know that the base events are being generated by the engine or the proc.

My problem is to understand the behaviour of the EVENT INITIALIZE.
From my tests I can figure out that the INITIALIZE EVENT is being fired several times in the processing of the proc print. I am having troubles with this, I was expecting to get it triggered once at the beginning of the proc print.
I think it explains why when I am running the section : FINISH: of the TABLE_BODY event I do have my memory variables available anymore.

I track it to tehc support now.
SAS Super FREQ
Posts: 8,745

Re: TEMPLATE TAGSET EVENT INITIALIZE

That -is- very odd. (That you are seeing initialize fire more than 1 time with PROC PRINT). When I test your TAGSET.TEST2 with PROC PRINT, I only see INITIALIZE being triggered once. Here's the output I get:
[pre]
====initialize:start:====
testvar: 4
===================
test
******doc_body:start:*********
testvar: 3
*******************
test
******table_body:finish:********
testvar: 3
myvalues: 3
*******************
******doc_body:finish:*******
testvar: 3
myvalues: 3
*******************
[/pre]

The tagset code I'm using is the same as your code, exactly the same as your code, and the output I'm getting is shown above. The invocation code is:
[pre]

ods tagsets.test2 file='c:\temp\test2_out.xml';
proc print data= sashelp.class(obs=3) ;
title 'proc print title';
run;
ods tagsets.test2 close;
[/pre]

Even when I added BY group processing to the PROC PRINT, I only saw INITIALIZE getting triggered 1 time. When I used BY with NEWFILE, I still saw INITIALIZE only get triggered 1 time. So, it's a puzzle.

Since you do plan to use this TAGSET template for a Stored Process, it's probably best that you work with Tech Support. They can look at your exact code and your plans for the stored process and give you the best advice.

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 163 views
  • 0 likes
  • 2 in conversation