BookmarkSubscribeRSS Feed
SAS Employee RMP
SAS Employee

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.





  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.




Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


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
  • 1 reply
  • 2 in conversation