#!/bin/bash
#<pre><b>
# Script     : intitlis
# Version    : 1.0
# Author     : Roland Rashleigh-Berry
# Date       : 19-Jul-2007
# Purpose    : Production script to list all the programs in the titles dataset
#              with corresponding lis filenames (uses SAS).
# SubScripts : intitlis_win
# SubMacros  : %allocr
# Notes      : There will be no .sas extension for the program name. There is
#              one line per .lis file in the form:
#              progname progname.lis
# Usage      : intitlis
#
#===============================================================================
# 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.
#===============================================================================

# No parameters required
if [ $# -gt 0 ] ; then
  echo "Error: (intitlis) Do not supply any parameters" 1>&2
  exit 2
fi


# if a Windows config then call intitlabels_win and exit on return
if [ -n "$CYGWIN" ] ; then
  intitlis_win
  exit $?
fi


# Feed SAS code into standard input
sas -stdio -sasuser work 2>/dev/null << -----FINISH-----
%allocr
options validvarname=v7 nofmterr noovp nodate nonumber;
proc sort nodupkey data=&_ptlibref_..titles(where=(type='T' and number=1))
                    out=_titles;
  by program label;
run;
data _null_;
  length lisfile $ 38;
  file stdout;
  set _titles;
  if lisfile=" " then lisfile=trim(program)||".lis"||left(label);
  put @1 program lisfile;
run;
-----FINISH-----
