#!/bin/sh
#<pre><b>
# Script     : showlfmts_win
# Version    : 1.0
# Author     : Roland Rashleigh-Berry
# Date       : 11-Feb-2007
# Purpose    : To display a list of formats stored in the current directory
#              in a catalog named FORMATS (uses SAS).
# SubScripts : none
# Notes      : WINDOWS VERSION
#              It will assume that the catalog containing the local formats will
#              be named "formats.sas7bcat"
# Usage      : showlfmts_win
#
#===============================================================================
# PARAMETERS:
#-pos- -------------------------------description-------------------------------
# N/A  Do not supply any parameters
#===============================================================================
# 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.
#===============================================================================

# Write SAS code to a temporary file
cat > $HOME/showlfmts_$$.sas << -----FINISH-----
filename _outfile "$HOMEW\showlfmts_$$.tmp";
libname here '.' access=readonly;
proc format lib=here cntlout=here(keep=fmtname type);
run;
data showlfmts;
  length name $ 8;
  set here;
  if type in ('C','P','N');
  if type='C' then name='$'||fmtname;
  else name=fmtname;
run;
proc sort nodupkey data=showlfmts;
  by name;
run;
data _null_;
  file _outfile notitles noprint;
  set showlfmts;
  put @1 name;
run;
-----FINISH-----

# run the code
sas -nosplash -nologo -icon -log "$HOMEW" -sysin "$HOMEW\showlfmts_$$.sas"

# if output file exists then cat it and delete it
if [ -f $HOME/showlfmts_$$.tmp ] ; then
  cat $HOME/showlfmts_$$.tmp 
  rm -f $HOME/showlfmts_$$.tmp 
fi

# tidy up
rm -f $HOME/showlfmts_$$.sas $HOME/showlfmts_$$.log
