05-15-2012 03:01 PM
Lets asume you have a dataset A. We then create another dataset B and a view C that are exact copies of A. If we then make a change to dataset A by adding or removing rows, etc. there will be no change to dataset B until we programatically update. The view C, however, will be updated without submitting any statements.
create view C as
select * from A;
where val ne 2;
proc print data=B;
proc print data=C;
05-15-2012 06:28 PM
Views may also be created to reference non-SAS data sources. Suppose you have a process that outputs a text file with the same name daily such as "d:\project\output.text". You could have a SAS view reference that data source. Each time the VIEW is used it re-reads that data so it always has the freshest version. If you place the VIEW in a permanent library such as below you only need to reference it like any other data set an it will re-read the data. Drawback: It re-reads the data every time it is referenced. If the external file is large the performance could be a significant problem.
data mylib.project / view=mylib.project;
infile "d:\project\output.text" (various options as needed);
I find views very useful when the component data sets are not terribly large but change frequently so the combined result doesn't require me to remember to rebuild everytime.
05-15-2012 08:15 PM
Another feature: views don't take up space. They save the instructions for how to extract data, rather than the data itself. This program needs to store a new data set:
tot_liquid = 2* pints + 4*quarts;
proc means data=totals;
But by making a small change, and creating a view instead of a data set, the storage space requirements are virtually eliminated:
data totals / view=totals;
(The rest of the program remains the same.)
05-15-2012 10:51 PM
View only contains the information using to search the real data (i.e. you can call it as SAS Code or SQL code), which doesn't contain any real data.
Table is actually dataset which contain the real data.