#!/bin/bash
#<pre><b>
# Script     : fsvraw
# Version    : 1.0
# Author     : Roland Rashleigh-Berry
# Date       : 04-Aug-2003
# Purpose    : To launch fsview to browse a SAS dataset in the current directory
#              (without user-defined formats applied) (uses SAS).
# SubScripts : none
# Notes      : Make the data directory the current directory. When fsview is
#              invoked it will go into command line mode and will attempt to
#              make "patient" the id variable. This task is run in background so
#              you can continue to use your xterm window for other tasks.
#              
#              Only native sas formats are applied to the data. User-defined
#              formats will default to suitable native alternatives.
#
#              If you give a SAS dataset file extension, the extension will be
#              ignored.
#
#              The toolbox window is closed on startup. If you wish to use it 
#              then issue the command "toolopen" on the fsview command line.
#
# Usage      : fsvraw demog
#              fsvraw demog.sas7bdat
#
#===============================================================================
# PARAMETERS:
#-pos- -------------------------------description-------------------------------
#  1   Name of SAS dataset
#===============================================================================
# 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 [ $# -lt 1 ] ; then
  echo "Usage: fsvraw SAS-dataset" 1>&2
  exit 1
fi

dset=$(echo $1 | cut -d. -f1)

sas -noautoexec -sasuser work -nofmterr \
-initstmt "libname here './'" \
-initcmd "fsview here.$dset;toolclose;command;show id patno" &
