SAS--chapter5

引用外部原始文件

libname clinic ’D:\SAS‘;         *同样要指定libref,DATA STEP可以输出到这个libref;

filename test0  'D:\test2\test1.dat';   *给test1.dat原始数据文件一个名为test0的fileref, 为了后面infile用。filename也可以指定为一个文件夹,infile做相应的改变;

infile test0 ;    *引用test0对应的原始数据文件。当filename指定的是一个文件夹,filename test0 'D:\test2';  infile test0 (test1.dat)/ infile test0 ('test1');

infile 'D:\test2\test1.dat';   *可以直接引用原始数据文件;

input ID $ 1-4 Age 6-7 ActLevel $ 9-12 Sex $ 14;  *给原始数据加变量名,character 加$,数字不用,原始数据文件需要满足以下standard;

infile tests obs=10;   *obs=10表示只能有10个观察单位,那么方便我们验证是否正确读取了数据。如果数据正确,去掉BOS=10,再运行该行代码;

直接添加变量:

在原有的变量上计算,赋值给变量本身:

猜你喜欢

转载自www.cnblogs.com/super-yb/p/11613965.html
SAS