|
Zio:
SAS-L is the listserver that you are using to post questions.
Jim has suggested several ways of creating the equivalent of a scalar value
in a SAS program. I'll trace through the extreme case of a SAS SQL program:
/* Create observations in a SAS dataset (which SAS SQL reads as a table). */
data work.test;
input x;
cards;
5
3
7
2
9
;
run;
/* Create a one-column, one-row table equivalent to a scalar variable. */
proc sql;
create table work.y (y num(3));
insert into work.y set y=6;
quit;
/* Multiply each row in the table work.test by the value assigned to
a degenerate table of relvar type 'cell' (scalar variable).
*/
proc sql;
create table z as select test.x * y.y as z
from work.test inner join work.y on 1 /* 1 in SAS SQL means 'true'*/
; /* when used as an argument.*/
quit;
Once a programmer builds a loop construct to read a file, an equivalent
program written in a procedural language requires much the same overhead. As
applications become more complex, procedural language constructs become much
more complex than equivalent set-logic constructs of SQL.
Different programming problems have inspired very different programming
languages: C, Lisp, APL, SQL, Forth (an OOP precursor), and Prolog, for
example. The SAS Data step and SQL operate on rows/obs in tables/datasets as
opposed to sequences of bytes, sequences of tokens, functions of variable
arguments, data objects, or propositions. Once you see a wider range of
operations on data structures, symbolic pointers to memory locations (scalar
variable names) will not seem as fundamental or critical to programming.
Sig
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Zio
Fester
Sent: Monday, July 19, 2004 10:05 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: creating a scalar variable
In article <446DDE75CFC7E1438061462F85557B0F027E6C68
@remail2.westat.com>, HERMANS1@WESTAT.COM says...
> Zio:
> I hope that your instructor doesn't subscribe to SAS-L!
Please forgive my ignorance, but what does that happen to be?
> Whatever his or her
> skill level, it does turn out that SAS, like many other so-called
> 'database programming languages', operates on actual or virtual
> tables. A table can degenerate to a one-column, one-row cell that has
> many of the properties of a scalar. More typically, a database
> programmer combines tabular datasets to produce solutions to
> programming problems.
Does this mean that SAS can only "think" row by row and that there's no way
to create a scalar variable (or a 1x1 matrix...) accessible from any part of
my code?
> It takes a while to learn how to combine tabular datasets effectively.
> Once you learn how, you will be able to do more in less time and with
> fewer errors. Sig
|