[last updated - 30 July 2003]
Make your data directory your current directory to run contentsl. It will list your dataset with variable type, length, format and label. You can use this to check whether you have added all the labels to a dataset. You can list a few datasets if you want to. If you invoke it without parameters then it will run on the whole library.
#!/bin/sh # Script : contentsl # Version : 1.0 # Author : Roland Rashleigh-Berry # Date : 30 July 2003 # Contact : roland@rashleigh-berry.fsnet.co.uk # Purpose : To list the contents (in long form) of one or more datasets or a # whole library # SubScripts : none # Notes : Must be run with data directory as current directory # Usage : contentsl demog # contentsl demog elig # contentsl # #================================================================================ # PARAMETERS: #-pos- -------------------------------description-------------------------------- # 1 one or more datasets (optional - will work on whole library by default) #================================================================================ # AMENDMENT HISTORY: # init --date-- mod-id ----------------------description------------------------- # #================================================================================ # This is public domain software. No guarantee as to suitability or accuracy is # given or implied. User uses this code entirely at their own risk. #================================================================================ if [ -f $HOME/contentsl.sas ] then echo "You will need to back up your SAS program CONTENTSL.SAS in your home" 1>&2 echo "directory and maybe its log file as this utility will overwrite it " 1>&2 exit 1 fi # Delete the output file if it already exists rm -f $HOME/contentsl.tmp 2> /dev/null if [ $# -lt 1 ] then ###### no datasets specified so do for the whole library ##### # Write SAS code out to a temporary file cat > $HOME/contentsl.sas << FINISH options validvarname=any nofmterr; proc format; value type 1='N' 2='C'; run; libname here './' access=readonly; filename _outfile '$HOME/contentsl.tmp'; proc contents noprint data=here._all_ out=contents; data contents; length newfmt $ 15; set contents; newfmt=format; if formatl>0 then do; newfmt=trim(newfmt)||compress(put(formatl,3.))||'.'; if formatd>0 then newfmt=trim(newfmt)||compress(put(formatd,3.)); end; else if newfmt ne ' ' then newfmt=trim(newfmt)||'.'; data _null_; file _outfile notitle noprint; set contents; put @1 memname @10 name @21 length @25 type type. @27 newfmt @40 label; run; FINISH # Run the SAS code sas -log "$HOME" -sysin "$HOME/contentsl.sas" # Delete the temporary SAS code and optionally the log rm -f $HOME/contentsl.sas # $HOME/contentsl.log # If output file exists then cat it and delete it if [ -f $HOME/contentsl.tmp ] then cat $HOME/contentsl.tmp rm -f $HOME/contentsl.tmp fi else ########### one or more dataset specified so do for each ######### for dataset in "$@" ; do # Write SAS code out to a temporary file cat > $HOME/contentsl.sas << FINISH options validvarname=any nofmterr; proc format; value type 1='N' 2='C'; run; libname here './' access=readonly; filename _outfile '$HOME/contentsl.tmp'; proc contents noprint data=here.$dataset out=contents; data contents; length newfmt $ 15; set contents; newfmt=format; if formatl>0 then do; newfmt=trim(newfmt)||compress(put(formatl,3.))||'.'; if formatd>0 then newfmt=trim(newfmt)||compress(put(formatd,3.)); end; else if newfmt ne ' ' then newfmt=trim(newfmt)||'.'; data _null_; file _outfile notitle noprint; set contents; put @1 memname @10 name @21 length @25 type type. @27 newfmt @40 label; run; FINISH # Run the SAS code sas -log "$HOME" -sysin "$HOME/contentsl.sas" # Delete the temporary SAS code and optionally the log rm -f $HOME/contentsl.sas # $HOME/contentsl.log # If output file exists then cat it and delete it if [ -f $HOME/contentsl.tmp ] then cat $HOME/contentsl.tmp rm -f $HOME/contentsl.tmp fi done fi
Go back to the home page.
E-mail the macro and web site author.