*
;

/*
Date: Fri, 31 May 1996 17:02:00 -400
Sender: "SAS(r) Discussion" 
From: Lewis Carson 
Subject: sas formats to html


hi,

here is a snippet of SAS that will take your format library and make a
 single html document out of it, with an index at the top which points to the
actual contents of the format below.  it is somewhat of a kludge in that it has
 hardwired stuff and is not as general as it could be, but here it is, if you
don't want to merge in external descriptions then snip out the second and third
 data steps.

 warning - don't put any really large formats in here or you may run into memory
 and time constraints upon display (i call large formats those with
over 1000 lines).

lewis

Lewis Carson
University Planning and Analysis, NC State University
Box 7002, 201 Peele Hall  Raleigh, NC  27695
phone (919) 515-6208   fax (919) 831-3541
***snip here*************************************************** */

        * frm2html.sas ;
        * html listing of formats ;

        %let title = UPA Formats;
        %let dirform = C:\TMP\;
        %let delform = ('$FLOUC' '$PADMTIT');   * delete these formats;

        proc catalog catalog = library.formats;
        contents out=formds;
        run;

***************************************************
***** get index information and merge in desc *****;

data formds2; set formds;
        length keylen textlen $3;
        if type = 'FORMATC' then name = '$' || substr(name,1,7);
        keylen = scan(desc,2);
        textlen = scan(desc,3);
        if name in &delform then delete;
        label name = 'Name'
                keylen = 'Key Length'
                textlen = 'Text Length'
                date = 'Last Updated'
                ;
        keep name keylen textlen date;
        run;


        filename formds3 "&dirform.formds2.txt";
data formds3; infile formds3 delimiter='09'x dsd firstobs=2 pad;
        input name : $8. desc $40.;
        label desc = 'Description';
        run;

        proc sort data = formds2; by name; run;
        proc sort data = formds3; by name; run;

data formds4; merge formds2(in=in2) formds3; by name;
        if in2;
        run;

**************************************
***** get individual format lines ****;

        proc format cntlout=formdata library=library.formats;
        run;

        proc sort data = formdata; by fmtname type; run;

data fd2; set formdata; by fmtname type;
        length name $8;
        if type = 'C' then name = '$' || substr(fmtname,1,7);
                else name = fmtname;
        if name in &delform then delete;
        keep name start end label;
        run;

        proc sort data=fd2; by name; run;

*****************************************
***** write index portion of document ***;

data formout1; set formds4 end=endofile;
        length htmline $200;
        if _n_ = 1 then do;
                htmline = "<h1>" || "&title" ||
 "</h1>












" || "&title" || "

"; output; htmline = "
"; output; htmline = ""; output; htmline = ""; output; end; htmline = ""; output; htmline = ""; output; if endofile then do; htmline = "
Name Key Length Text Length Last Updated Description
" || "

" || name || "

" || "
" || keylen || "" || textlen || "" || date || "" || desc || "
"; output; end; keep htmline; run; ***************************************** ***** write individual format sections **; data formout2; set fd2 end=endofile; by name; length htmline $200; if first.name then do; htmline = "

" || name || "

"; output; htmline = ""; output; end; htmline = ""; output; if last.name then do; htmline = "
Start End Label
" || trim(Start) || "" || trim(End) || "" || trim(Label) || "

Back to the Index

"; output; end; keep htmline; run; ***************************************** ***** write trailer **; data formout3; length htmline $200; input htmline; cards; ; run; ***************************************** ***** write ds to disk *****; filename htmlout "&dirform.formats.htm"; data _null_; set formout1 formout2 formout3; file htmlout; put htmline; run; *
;