Date: Fri, 10 Dec 1999 20:09:31 -0800
Reply-To: Walter Smith <wjsmith1NOwjSPAM@FEDEX.COM.INVALID>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Walter Smith <wjsmith1NOwjSPAM@FEDEX.COM.INVALID>
Organization: http://www.remarq.com: The World's Usenet/Discussions Start Here
Subject: Re: Free alternatives to Base/SAS
OK, I'll put the porqupine quills away. Seems that we agree more than
disagree, but I missed that in your first post. However, I'm puzzled
about:
> But think about it. How many times have you had to deal with starting
> values, etc., in SAS, when you knew that if you could resolve the > >
problem to a basic summand + functional; statement you could skip
> all that?
Are you talking about something like this?:
<pre>
1 data blue;
2 do until(x=10);
3 x+1;
4 sumx+x;
5 sumx2+x*x;
6 put x= sumx= sumx2=;
7 end;
8 run;
X=1 SUMX=1 SUMX2=1
X=2 SUMX=3 SUMX2=5
X=3 SUMX=6 SUMX2=14
X=4 SUMX=10 SUMX2=30
X=5 SUMX=15 SUMX2=55
X=6 SUMX=21 SUMX2=91
X=7 SUMX=28 SUMX2=140
X=8 SUMX=36 SUMX2=204
X=9 SUMX=45 SUMX2=285
X=10 SUMX=55 SUMX2=385
NOTE: The data set WORK.BLUE has 1 observations and 3 variables.
NOTE: DATA statement used:
real time 0.040 seconds
cpu time 0.028 seconds
</pre>
Yes, the sytax is x+1, not like Perl's x++ but...
> but I use those hacks in quick ways that make Perl useful when SAS
> is more work. How many lines of SAS code would you need to write a
> program to read through a file and count the number of commas which
> were not preceded by a backslash or immediately followed by another
> comma?
I agree that for many things, Perl or even awk or shell commands excel.
An example: the very simple unix command "id". stdout is easily
manipulated by many unix tools, but to read a pipe in SAS, I recently
wrote:
<pre>
/***********************************************************
* Name: getusrid *
* Desc: Get the users Unix userid. *
* Type: Macro Function - Unix *
* *
* Usage: %let macro-var-name = %getusrid; *
* *
* Walt Smith November 30, 1999 *
***********************************************************/
%macro getusrid;
%local fref rc fid userid;
%let rc =%sysfunc(filename(fref,id,pipe)); %*define fileref as
pipe;
%let fid=%sysfunc(fopen (&fref,s)); %*open fileref (pipe);
%let rc =%sysfunc(fread (&fid)); %*read into buffer;
%let rc =%sysfunc(fget (&fid,inrec)); %*copy into variable;
%let rc =%sysfunc(fclose (&fid)); %*close fileref;
%let rc =%sysfunc(filename(fref)); %*clear fileref;
%let userid=%scan(&inrec,2);
&userid
%mend;
</pre>
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!