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.
Regards
Richard
Hi:
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…
http://support.sas.com/documentation/cdl/en/odsug/66611/HTML/default/viewer.htm#n0luvkrmcfepfen1wmf0... 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;
done;
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.
cynthia
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.