Date: Wed, 10 Jul 2002 15:51:06 -0500
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Greg Woolridge <greg.woolridge@TAP.COM>
Subject: Re: A datastep question...
Content-type: text/plain; charset=us-ascii
The problem is that SAS needs the variable in the data vector in order for
the WHERE to execute. You might try using DROP= on your output data set as
DATA Inputdata (drop=ID3);
I have not tried this before, so I am not sure that it will work, but it is
the only way I can think of to possibly do what you want in a single DATA
Greg M. Woolridge
Manager, Study Programming
TAP Pharmaceutical Products Inc.
<bmeyer67@CALVIN To: SAS-L@LISTSERV.UGA.EDU
Sent by: "SAS(r) Subject: A datastep question...
Well, not necessarily a datastep, but...
I have been starting to use WHERE clauses in set statements to limit my
data instead of using the subsetting-IF. However, I still find that I
need to have the COLUMN that I am using in the WHERE clause to in order
to run the step.
SET DB.Input(KEEP=ID1 ID2 ID3 WHERE=(ID3=&X);
If I needed ID3 later on, then I wouldn't mind having to have it in the
returned columns. However, I don't and it takes up space. (I remove it
at the next time that I subset my data, such as a PROC MEANS procedure.)
Now, if I were to implement this SQL, I don't need to have the column
CREATE TABLE InputData AS
SELECT ID1,ID2 FROM DB.Input WHERE ID3=&X;
Is there some way that with the DATA step's (or PROCs if it were to be
done there) that I could drop a column but use it in the WHERE?
Note: This is not a question of SAS vs. SQL. But a question of SAS in
how to do it, or why can't it be done? If I were worried about space,
the SQL may be more appealing even though it takes a little longer to
run, at least in my test scenario from one of my scripts. (Difference in
time is 8.57 seconds real time, and 9.98 seconds CPU time. That also
includes a sort, and the data step is done through a PROC SORT
Benjamen R. Meyer