%macro gendsrpt( /* This macro will generate a report (html page) summarizing the datasets within a data library. It will use data contained in the datasets dataset of the specified data lib along with data obtained from running proc contents on the library. The generated page contains, among other things, hyperlinks to our metadata (display datasets dataset) application. Output is written to the file Datasets.html in the directory (folder) corresponding to libname (derived from libpath). Code by John Blodgett, OSEDA, under contract with the Missouri Census Data Center, 2/03. */ revdate=2/5/2003 4:59PM, /* 4/1/2003 10:37AM it was "disabled" */ libname=, /* this is the library to generate the report for. A libname stmt must be used in the invoking program to define this libref, normally with read/write access */ runprocc=0, /* Specify runprocc=1 to indicate you want/need to run the proc contents step. The program will check to see if the set libname.datasets_contents exists and will invoked the proc contents step to create it if (and ONLY if) it does not. */ debug=0); %put This macro is obsolete... use gendshtm macro instead!!! ; %goto endmac; %if &debug %then %put **** gendsrpt, rev. &revdate, begin execution ****; %if &runprocc=1 or (%sysfunc(exist(&libname..datasets_contents))=0) %then %do; *----Generate a Datasets.html file in the current directory based on dataset info from the datasets dataset and proc contents----; proc contents data=&libname.._all_ noprint out=datasets_contents( keep=memname memlabel nobs crdate engine varnum where=(varnum=1 and lowcase(memname) ne 'datasets_contents') rename=(crdate=created)); run; data &libname..datasets_contents; set datasets_contents; memname=lowcase(memname); drop varnum; format created datetime7.; run; proc sort data=&libname..datasets_contents; by memname; run; %end; %if %sysfunc(exist(&libname..datasets))=0 %then %do; %put; %put; %put ******ERROR: No datasets dataset found in specified library &libname ******; %goto endmac; %end; data allsets; update &libname..datasets_contents &libname..datasets (where=(libname="&libname" and SortPrio ne "X") in=indatasets); by memname; if not indatasets then sortprio="9"; format created datetime7.; if indatasets then call symput('libpath',trim(libpath)); run; proc sort data=allsets; by SortPrio GeoUniv SetGroup Memname; run; %if &sysscp=WIN %then %let slash=%str(\); %else %let slash=%str(/); proc format; *--the $tb format will cause a character to be put in the cell so it will not be empty when value is blank; value $tb ' '=' '; run; data _null_; set allsets end=last; %let libpath= %sysfunc(pathname(&libname)); file "&libpath&slash.Datasets.html" lrecl=500; if _n_=1 then do; put "
| # | Name | Label | ' '#Rows | #Cols | Geographic Universe | '
'Units | Link to Details |
Size in KB |
Created | Eng |
| ' _n_ ' | ' memname ' | ' memlabel $tb. ' | ' nobs comma7. ' | ' nvars comma7. ' | ' GeoUniv $tb. ' | ' Units $tb. ' | '; put ''; if GeoUniv ne " " or Description ne " " then put 'Details | '; else put ' NA '; put '' kbytes comma9. ' | ' created datetime7. ' | ' engine $3. ' | ' ; put '