BookmarkSubscribeRSS Feed
Mike_Davis
Fluorite | Level 6


Hello All.

Does anybody can briefly tell me  the difference between view and dataset? best with a small example.

Thanks!

Mike

4 REPLIES 4
RickM
Fluorite | Level 6

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.

data A;

val=1; output;

val=2;output;

val=3;output;

run;

data B;

set A;

run;

proc sql;

create view C as

select * from A;

quit;

data A;

set A;

where val ne 2;

run;

proc print data=B;

run;

proc print data=C;

run;

ballardw
Super User

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);

    input variables;

run;

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.

Astounding
PROC Star

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:

data totals;

  set liquids;

   tot_liquid = 2* pints + 4*quarts;

run;

proc means data=totals;

   var tot_liquid;

run;

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.)

Ksharp
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1001 views
  • 3 likes
  • 5 in conversation