| Date: | Wed, 5 Jun 2002 16:39:16 +0100 |
| Reply-To: | Peter Crawford <peter.crawford@DB.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Peter Crawford <peter.crawford@DB.COM> |
| Subject: | Re: Dynamically assigning values to columns |
|
| Content-type: | text/plain; charset=iso-8859-1 |
if you want something dynamic, don't store the result !
Just store the formula !
There is nothing "one-off" about a view !
Depending on the context where you will
use theis dynamic result, the sas system offers
a choice of solutions.
When you separate the data and "dynamic formula"
you'll need a reliable way of bringing them together.
A common solution offered will store the data and
formulas in the same place. However, they are very
different physical objects. That encourages a
designer to separate them. You only need a
reliable way of connecting them. Suddenly,
it seems you need libref defined for each source
component of your data used in the view, as well
as the libref for the view !
Fortunately, sql allows a libname to be defined
within the view
Here is an example:
Your oracle databases provide a substantial
set of data, but not everything you need. You want
to calculate some more items.
You have only read access
In Version 8, this embedding of the libname definition
is demonstrated in on line doc
which I extended a little to create an output view
and derive columns
proc sql;
create view last_straw as
select tab1.deptno, dname
, &formulas /* deriving new columns */
from
dblib.table1 tab1
dblib.table2 tab2
where tabl.deptno = tab2.deptno
using libname dblib oracle user=scott
password=tiger path='myserver';
quit;
/* &formula is deriving the extra columns
interrogate your meta data to populate &formulas like
%let formulas =
today() - date_of_birth label='age in days' as age ,
event_date - today() as days_left
;
Or this might be populated programatically.
good luck
Peter Crawford
Datum: 03/06/2002 13:52
An: SAS-L@LISTSERV.UGA.EDU
Antwort an: Deepak Ramanathan <deepakramanathan@YAHOO.COM>
Betreff: Dynamically assigning values to columns
Nachrichtentext:
Hi all,
I have a column which displays the date a particular event will occur.
I need to create a column that will display the number of days left
for that event but I need this to be dynamically changed based on the
current date..
i.e.
today(03/06/02) the table will look like
event_date days left
10/06/02 7
tommorow(04/06/02) the same table will look like
event_date days left
10/06/02 6
I tried assigning the column a value of
days_left = event_date - today()
but that stores it in the table as a one off thingy...
Any suggestions?
Deepak
--
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
|