The SAS Output Delivery System and reporting techniques

Proc Template: numeric index value not being recognised?

SAS Employee RMP
SAS Employee
Posts: 52

Proc Template: numeric index value not being recognised?

Hi folks,

I am trying to create a tagset for a specific export file. I am having some difficulties getting a 'loop' construct to work. Can someone tell me why this code works when I specifically assign the index value and why it does not work when using a variable?

   eval $loop 1;

   putlog $address_context[1];                  /* this line produces the desired output namely the first item in my array */

   putlog $address_context[$loop];           /* this line produces nothing */

Any help would be very much appreciated.



Posts: 9,365

Re: Proc Template: numeric index value not being recognised?


  I didn’t use PUT/PUTLOG the way you do in your TAGSET template. It sounds like you are designing a template for use with the SAS XML Libname engine, correct? Not for use with ODS?

  Mostly, I used PUTLOG and PUT to write out  quoted “pairs”, so for example…if I had PUT I used it sort of like they show in the doc…      where it says that

If the variable does not have a value, then the text is not  written, and there is no output for the text or the variable. For example, for
the following PUT statement, if the variables BackGround, ForeGround, and CellPadding do not have values, then the output is <table> followed by a new line:

put '<table' 'background=' background 'foreground=' foreground 'cellpadding=' cellpadding '>' nl;


    So I used PUT in the same way for writing out the attribute/value pairs easily to generate custom XML. If there WAS a value for the BACKGROUND attribute, then background=cx123456 would be
written, but if there was no value for background, then no part of the text string would be written. I found some old PROC TEMPLATE code that use a similar reference to what you show. The code I
found was in a DO/DONE block, but with a SET and $col_names[$index], which, as I remember resolved just fine, but it was not using the reference in a PUT
statement in PROC TEMPLATE:

do /while $index <= $count;

            set $name  $col_names[$index] ;

            set $value $col_values[$name] ;

            trigger EmitCol ;

            eval $index $index+1;



  So I’m not sure what is different about PUT/PUTLOG…in your example, it is puzzling how it can find a value when the 1 is hard-coded, but not when the value is set to 1 and you use the internal variable.

  I think your best resource will be working with As far as I know, the only folks who write custom tagsets are in Tech Support or folks who use the XML Mapper to generate .map files for use with the XML Libname engine.



Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation