Date: Wed, 3 Oct 2001 15:09:14 -0700
Reply-To: "Karsten M. Self" <kmself@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Karsten M. Self" <kmself@IX.NETCOM.COM>
Subject: Re: Off-topic: Bourne script
In-Reply-To: <Pine.GSO.4.05.10110031305280.1260-100000@medusa.harvard.edu>;
from casey@SDAC.HARVARD.EDU on Wed, Oct 03,
2001 at 01:21:53PM -0400
Content-Type: multipart/signed; micalg=pgp-sha1;
protocol="application/pgp-signature";
on Wed, Oct 03, 2001 at 01:21:53PM -0400, Casey Pierce (casey@SDAC.HARVARD.EDU) wrote:
> Apologies for the off-topic-ness:
>
> I'm writing a bourne script to ask the user questions and
> write the answers to a SAS macro. I don't have any formal
> training with UNIX scripting, just taught myself bits here
> and there, but I need all sorts of help with the below
> situation and I'm hoping someone on this list can help out.
>
> The SAS macro required the user to input a list of study
> weeks they would like analyzed. Then, in a proc format,
> they can specify the windows to go around those weeks, so
> if a user wants 2-week windows, it might look something like this:
>
> proc format;
> value weekfmt
> -2 <- 2 = "0"
> 6 <- 10 = "8"
> 14 <- 18 = "16"
> ;
> run;
>
> %DAR( ... WEEKS = 0 8 16, ...);
>
> In the script so far, I have an argument "weeks" that successfully
> takes value 0 8 16. What I'd like to do next is be able to prompt
> the user once for each week, to specify the range for that
> week. I'd like to call these ranges window1, window2, ...
> depending on how many values in "weeks." Below is my current
> syntax for this part, and the errors I'm getting. I can't
> make $i increase by 1 - that's the main problem. But then
> I'm sure there's a problem with refering to window$i.
> Any insight at all is greatly appreciated:
>
> ************************************************************************
> i=1
> for wk in $weeks; do
> window$i=""
> while [ -z $window$i ]; do
> echo "
> List the weeks to define week $wk as you would in a proc format:
> Example: -2 <-< 2 spans 2 weeks before and 2 weeks after week 0,
> not including either endpoint.
> "
> read window$i
> case $window$i in
> [Qq]* ) exit 1;;
> esac
> done
> i=expr "$i" + 1
i=$(( i + 1 ))
> done
> exit 1
>
> ************************************************************************
> i=1
> + window1=
> AVAILABILITY: window1=: not found
> + [ -z 1 ]
> + 1 + 1
> AVAILABILITY: 1: not found
> + window1=
> AVAILABILITY: window1=: not found
> + [ -z 1 ]
> + 1 + 1
> AVAILABILITY: 1: not found
> + window1=
> AVAILABILITY: window1=: not found
> + [ -z 1 ]
> + 1 + 1
> AVAILABILITY: 1: not found
>
> ************************************************************************
>
> Thanks,
>
> Casey
--
Karsten M. Self <kmself@ix.netcom.com> http://kmself.home.netcom.com/
What part of "Gestalt" don't you understand? Home of the brave
http://gestalt-system.sourceforge.net/ Land of the free
Free Dmitry! Boycott Adobe! Repeal the DMCA! http://www.freesklyarov.org
Geek for Hire http://kmself.home.netcom.com/resume.html
[application/pgp-signature]
|