Creating a data step view

原创 2011年10月17日 20:24:59 

THE details are from SAS Programming III :Advanced Techniques 

1 DATA Statement with VIEW= Option Syntax

data data-set-name / view=view-name;

        infile filref;

        input variables;


data view = view-name;



 2 Example

data ia.movingq work.movingq / view = ia.movingq;
   drop MonNum MidMon LastMon I today;
   today = today();
   MonNum = month(today);
   MidMon = month(intnx('month',today,-1));
   LastMon = month(intnx('month',today,-2));
   do I = MonNum, MidMon, LastMon;
      NextFile = "month"||put(i,2.)||".dat"; * Windows/UNIX;
*Nextfile = ".prog3.rawdata(month"!!put(i,2.)!!")"; /* z/OS */
      NextFile = compress(NextFile,' ');
      do until (LastObs);
         infile in filevar = NextFile end = LastObs;
         input Flight $ Origin $ Dest $ Date : date9.
               RevCargo : comma15.2;
proc print data = ia.movingq;
   title 'ia.movingq DATA Step View';
   title2 'triggers creation of work.movingq data set';
   var Flight Origin Date Dest RevCargo;
   format Date date9.;

3 Advantages

You can use DATA step views to do the following:
 a. combine data from multiple sources
 b. hide complex code from users
 c. access the most current data in changing files
 d. avoid storing a SAS copy of a large data file
 e. avoid creating intermediate copies of data

4 Guidelines

 1)If data is used many times in one program, it is more efficient to create and reference a SAS data file than
    to create and reference a view.

data staff; 
   set ia.sview; 
proc print data = staff; 
proc freq data = staff; 
   tables JobCode; 
proc means data = staff; 

2)Expect a degradation in performance when you use a SAS data view with a procedure that requires
multiple passes through the data.

proc print data = ia.sview uniform;

proc means data=ia.sview ;

        class ...;run;


3)Avoid creating views on files whose structures often change.

filename rawdata 'file1';
proc print data = ia.sview;
filename rawdata 'file2'
proc freq data = ia.sview;
tables JobCode;
filename rawdata 'file3'
proc means data = ia.sview;

Creating custom View - Creating a View Class

A well-designed custom view is much like any other well-designed class. It encapsulates a specific s...
  • faner200801
  • faner200801
  • 2015年03月04日 15:33
  • 253

Creating a Custom View

Creating a Custom View The NSView class acts mainly as an abstract superclass; generally you crea...
  • Koupoo
  • Koupoo
  • 2011年08月25日 11:50
  • 795

Creating a View

Creating a View CGRect  viewRect = CGRectMake(10, 10, 100, 100); UIView* myVie...
  • fire1986
  • fire1986
  • 2012年04月09日 20:48
  • 146

Creating a View on a Dialog

 Creating a View on a Dialog (continued) -->Environment: NT4 SP3
  • sding
  • sding
  • 2009年11月11日 20:34
  • 542

关于"net start mysql"提示"服务名无效"的启动mysql方法

关于"net start mysql"提示"服务名无效"的启动mysql方法
  • m0_37786859
  • m0_37786859
  • 2017年05月13日 12:02
  • 715

curl post上传文件的“failed creating formpost data“错误

之前写过一个php使用curl上传文件的代码,今天暴出了一个bug,curl错误信息为"failed creating formpost data" 先说一下curl上传文件的过程吧 ...
  • hll870909
  • hll870909
  • 2012年04月17日 19:25
  • 10186

Step by step: creating a virtual machine on a headless server

Step by step: creating a virtual machine on a headless server The following instructions may give y...
  • llc_xyz
  • llc_xyz
  • 2011年11月01日 00:35
  • 164

Data Step Hash Objects as Programming Tools(2)

A PEEK UNDER THE HOOD We have just seen the tip of the hash iceberg from the outside. An inquiring ...
  • yugao1986
  • yugao1986
  • 2011年08月29日 15:18
  • 698

curl提示failed creating formpost data

遇到的问题是在linux环境下php文件执行正常,在windows下执行不正常, 度娘得到的结果是
  • fhl0000
  • fhl0000
  • 2015年02月15日 12:56
  • 1801

Creating a custom data descriptor

Creating a custom data descriptorIf your hierarchical data does not fit the formats supported by the...
  • shangmw
  • shangmw
  • 2008年08月28日 16:47
  • 896
您举报文章:Creating a data step view