/* This is /mscdc/sasmacro/td.sas */
/********************************************************************
* NAME: td SYSTEM: MSCDC PGMR: BLODGETT *
* FUNCTION: Generates the SAS "put" statements to write HTML TD *
* (and basic TR) entries with content consisting of SAS variable *
* values or literals. *
* NOTES: *
********************************************************************/
%GLOBAL REVDATE; %LET REVDATE=12JUN96; *<----DATE OF LAST REVISION;
/********************************************************************/
/* BEGIN MACRO DEFINITION */
/********************************************************************/
/* END */
%macro td(v, /* value (text) for the TD item. Can either be the name
of a SAS variable or a literal. Program will assume its a
literal if enclosed in double quotes or if longer than 8 */
format=, /* this and the following parms has the same name as the
TD option. Specifying a value for any of these parms
causes the value to be passed as the TD option. */
width=,
align=, /* if you leave this blank the macro will assign the value
"right" if v is a variable. */
bgcolor=,
colspan=,
rowspan=,
href=, /* the value can be made a hyper-link by specifying the
URL of the link. Most such URLs will require using the
str macro quoting function to avoid syntax problems */
th=0, /* Specify "th=1" to cause output to be an
spec instead
of | (a header cell instead of a data cell). */
newrow=0, /* Specify newrow=1 to cause a " | " to be put */
endrow=0 /* Specify endrow=1 to cause a "
to be put */
);
%PUT %STR( );
%PUT ***************************************************************;
%put * td macro Rev &revdate begin execution *;
%put * Missouri State Census Data Center *;
%PUT ***************************************************************;
%PUT %STR( );
%local qv lit;
%let qv=%bquote(&v);
%if &qv eq %str() %then %do;
%put *******td macro invoked without value for required positional parm***;
%goto endmac;
%end;
%local td2;
%if &th %then %let td2=TH; %else %let td2=TD;
%if %qsubstr(&qv,1,1) eq %str(%") or %length(&qv) gt 8 %then %let lit=1;
%else %let lit=0;
%if &newrow %then %do; put " "; %end;
put "<&TD2 "
%if &width ne %then " WIDTH=&width ";
%if &align ne %then " ALIGN=&align ";
%else %if &lit=0 %then " ALIGN=RIGHT " ;
%if %bquote(&colspan) ne %then " COLSPAN=&colspan ";
%if %bquote(&rowspan) ne %then " ROWSPAN=&rowspan ";
%if %bquote(&bgcolor) ne %then " BGCOLOR=&bgcolor ";
%if %bquote(&href) ne %then " ";
%str(">" )
%if &lit and %qsubstr(&qv,1,1) ne %str(%") %then
%let qv=%str(%")&qv%str(%");
%if &format ne %str()
%then %unquote(&qv) &format ; %else %unquote(&qv);
%if &href ne %then " ";
"&TD2> " @;
%if &endrow %then %do; put "
"; %end;
%endmac:
%mend td;