注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

数据挖掘

学习数据挖掘

 
 
 

日志

 
 

可以在%SYSFUNC中使用的SAS函数一览表  

2013-05-28 21:58:13|  分类: SAS |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
本文来源于西铁房临床试验爱好者中心(本帖最后发表人:西铁房版主Stanley)
转载请保留此链接:
http://www.clinicaltrialfans.com/posts/list/470.page

------------------过一遍,简单的翻译一遍-----------就看翻译的准不准了-------哈哈哈----------------------
ATTRC returns the value of a character attribute for a SAS data set. %SYSFUNC(ATTRC(data-set-id,attr-name)) 
--ATTRC  返回数据集中一些基本特征,例如 打开方式,标签等。
例如:
  • %let mode=%sysfunc(attrc(&dsid,MODE));
    %if &mode ne IS %then
       %put Data set has not been opened in INPUT SEQUENTIAL mode.;
    (判断数据集是不是以写入方式打开,不允许查看)

ATTRN returns the value of a numeric attribute for specified SAS data set. %SYSFUNC(ATTRN(data-set_id,attr-name)) 
---ATTRN 返回数据集中一个数值集合的一些性质,常用的是返回记录条数,变量个数。

%SYSFUNC(ATTRN(data-set_id,nobs)) --返回记录条数,where条件无效。


NOBS

specifies the number of physical observations (including those that are marked for deletion). An active WHERE clause does not affect this number.

-1

the number of observations is not available

%SYSFUNC(ATTRN(data-set_id,nvars)) --返回变量个数。



CEXIST verifies the existence of a SAS catalog or SAS catalog entry. %SYSFUNC(CEXIST(entry <, 'U'>)) 
--CEXIST 
CLOSE closes a SAS data set. %SYSFUNC(CLOSE(data-set-id)) 
--CLOSE  关闭一个打开的数据集
CUROBS returns the number of the current observation. %SYSFUNC(CUROBS(data-set-id)) 
CUROBS ---返回当前观测的数字

例子:

This example uses the FETCHOBS function to fetch the tenth observation in the data set MYDATA. The value of OBSNUM returned by CUROBS is 10.

%let dsid=%sysfunc(open(mydata,i));
%let rc=%sysfunc(fetchobs(&dsid,10));
%let obsnum=%sysfunc(curobs(&dsid));



DCLOSE closes a directory. %SYSFUNC(DCLOSE(directory-id)) ,如果操作成功,返回0.
---DCLOSE 关闭路径
例子:
%macro memnum(filrf,path);
%let rc=%sysfunc(filename(filrf,&path));
%if %sysfunc(fileref(&filrf)) = 0 %then
   %do;
         /* Open the directory. */
      %let did=%sysfunc(dopen(&filrf));
      %put did=&did;
         /* Get the member count. */
      %let memcount=%sysfunc(dnum(&did));
      %put &memcount members in &filrf.;
         /* Close the directory. */
      %let rc= %sysfunc(dclose(&did));
   %end;
%else %put Invalid FILEREF;
%mend;
%memnum(MYDIR,physical-filename)


DINFO returns a specified information item for a directory. %SYSFUNC(DINFO(directory-id,info-items)) 
---DINFO 返回一个路径的信息

This example opens the directory MYDIR, determines the number of directory information items available, and retrieves the value of the last one:

%let filrf=MYDIR;
%let rc=%sysfunc(filename(filrf,physical-name));
%let did=%sysfunc(dopen(&filrf));
%let numopts=%sysfunc(doptnum(&did));
%let foption=%sysfunc(doptname(&did,&numopts));
%let charval=%sysfunc(dinfo(&did,&foption));
%let rc=%sysfunc(dclose(&did));

Example 2: Using DINFO within a DATA Step

This example creates a data set that contains the name and value of each directory information item:

data diropts;
   length foption $ 12 charval $ 40;
   keep foption charval;
   rc=filename("mydir","physical-name");
   did=dopen("mydir");
   numopts=doptnum(did);
   do i=1 to numopts;
      foption=doptname(did,i);
      charval=dinfo(did,foption);
      output;
   end;
run;




DNUM returns the number of members in a directory. %SYSFUNC(DNUM(directory-id)) 
---DNUM  返回一个路径下的成员个数

Open the directory MYDIR, determine the number of members, and close the directory:

   /* Assign the fileref MYDIR to the          */
   /* filename stored in the variable DIRNAME  */
   /* and open it.                             */
rc=filename('mydir',dirname);
dirid=dopen('mydir');
memcount=dnum(dirid);
rc=dclose(dirid);



DOPEN opens a directory. %SYSFUNC(DOPEN(fileref)) 
--DOPEN 打开指定的路径
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
#
DOPTNAME returns a specified directory attribute. %SYSFUNC(DOPTNAME(directory-id,nval)) 
---DOPTNAME 返回一个路径的属性

DOPTNAME
(directory-id,nval)

directory-id

specifies the identifier that was assigned when the directory was opened, generally by the DOPEN function.

To use DOPTNAME on a directory, the directory must have been previously opened by using the DOPEN function.

nval

specifies the sequence number of the information item.

Example 1: Using DOPTNAME to Retrieve Directory Attribute Information

This example opens the directory with the fileref MYDIR, retrieves all system-dependent directory information items, writes them to the SAS log, and closes the directory:

%let filrf=mydir;
%let rc=%sysfunc(filename(filrf,physical-name));
%let did=%sysfunc(dopen(&filrf));
%let infocnt=%sysfunc(doptnum(&did));
%do j=1 %to &infocnt;
   %let opt=%sysfunc(doptname(&did,&j));
   %put Directory information=&opt;
%end;
%let rc=%sysfunc(dclose(&did));

Example 2: Using DOPTNAME within a DATA Step

This example creates a data set that contains the name and value of each directory information item:

data diropts; length optname $ 12 optval $ 40; keep optname optval; rc=filename("mydir","physical-name"); did=dopen("mydir"); numopts=doptnum(did); do i=1 to numopts; optname=doptname(did,i); optval=dinfo(did,optname); output; end; run;

#



#
DOPTNUM returns the number of information items available for a directory. %SYSFUNC(DOPTNUM(directory-id)) 
---DOPTNUM返回一个数值,一个路径中关于信息菜单的数量
The directory specified by directory-id must have been previously opened by using the DOPEN function.
使用之前需要使用Dopen函数打开目录
#





DREAD  returns the name of a directory member. %SYSFUNC(DREAD(directory-id,nval)) 
--DREAD 返回特定路径下某成员名字

Examples

This example opens the directory identified by the fileref MYDIR, retrieves the number of members, and places the number in the variable MEMCOUNT. It then retrieves the name of the last member, places the name in the variable LSTNAME , and closes the directory:

%let filrf=mydir; %let rc=%sysfunc(filename(filrf,physical-name)); %let did=%sysfunc(dopen(&filrf)); %let lstname=; %let memcount=%sysfunc(dnum(&did)); %if &memcount > 0 %then %let lstname=%sysfunc(dread(&did,&memcount)); %let rc=%sysfunc(dclose(&did));








DROPNOTE  deletes a note marker from a SAS data set or an external file. %SYSFUNC(DROPNOTE(data-set-id|file-id,note-id)) 
---DROPNOTE  删除指定的标记
DSNAME  returns the data set name associated with a data set identifier. %SYSFUNC(DSNAME(<dsid>)) 
EXIST  verifies the existence of a SAS data library member. %SYSFUNC(EXIST(member-name<,member-type>)) 
--EXIST 确定某成员的存在性
FAPPEND  appends a record to the end of an external file. %SYSFUNC(FAPPEND(file-id<,cc>)) 
--针对外部文件在末尾增加一条记录
FCLOSE  closes an external file, directory, or directory member. %SYSFUNC(FCLOSE(file-id)) 
---FCLOSE  关闭外部文件 路径
FCOL  returns the current column position in the File Data Buffer (FDB) %SYSFUNC(FCOL(file-id)) 
---FCOL返回当前列位置
FDELETE  deletes an external file. %SYSFUNC(FDELETE(fileref)) 
---FDELETE 删除一外部文件
FETCH  reads the next nondeleted observation from a SAS data set into Data Set Data Vector (DDV). %SYSFUNC(FETCH(data-set-id<,'NOSET'>)) 
---FETCH  读取SAS文件 下一个未删除的记录 到DDV
FETCHOBS  reads a specified observation from a SAS data set into the DDV. %SYSFUNC(FETCHOBS(data-set-id,obs-number<,options>)) 
---FETCHOBS 读取指定的记录到DDV
FEXIST  verifies the existence of an external file associated with a fileref. %SYSFUNC(FEXIST(fileref)) 
--FEXIST外部文件是否存在?
FGET  copies data from the FDB. %SYSFUNC(FGET(file-id,cval<,length>)) 
FILEEXIST  verifies the existence of an external file by its physical name. %SYSFUNC(FILEEXIST(file-name)) 

##########################################################################
FILENAME  assigns or deassigns a fileref for an external file, directory, or output device. %SYSFUNC(FILENAME(fileref,filename<,device<,hostoptions<,dir-ref>>>)) 
filename()的用法
sysrc=FILENAME(fileref,filename<,device <,host-options<,dir-ref>>>);

sysrc

contains the return code for the operation:

0

successful

[ne]0

not successful

Type: Numeric

This example assigns the fileref MYFILE to an external file, then deassigns the fileref. Note that in a macro statement you do not enclose character strings in quotation marks.

%let filrf=myfile; %let rc=%sysfunc(filename(filrf, physical-filename)); %if &rc ne 0 %then %put %sysfunc(sysmsg()); %let rc=%sysfunc(filename(filrf));

############################################################################################
FILEREF  verifies that a fileref has been assigned for the current SAS session. %SYSFUNC(FILEREF(fileref)) 
FINFO  returns a specified information item for a file. %SYSFUNC(FINFO(file-id,info-item)) 
FNOTE  identifies the last record that was read. %SYSFUNC(FNOTE(file-id)) 
FOPEN  opens an external file. %SYSFUNC(FOPEN(fileref<,open-mode<,record-length<,record-format>>>)) 
FOPTNAME  returns the name of an information item for an external file. %SYSFUNC(FOPTNAME(file-id,nval)) 
FOPTNUM  returns the number of information items available for an external file. %SYSFUNC(FOPTNUM(file-id)) 
FPOINT  positions the read pointer on the next record to be read. %SYSFUNC(FPOINT(file-id,note-id)) 
FPOS  sets the position of the column pointer in the FDB. %SYSFUNC(FPOS(file-id,nval)) 
FPUT  moves data to the FDB of an external file starting at the current column position. %SYSFUNC(FPUT(file-id,cval)) 
FREAD  reads a record from an external file into the FDB. %SYSFUNC(FREAD(file-id)) 
FREWIND  positions the file pointer at the first record. %SYSFUNC(FREWIND(file-id)) 
FRLEN  returns the size of the last record read, or the current record size for a file opened for output. %SYSFUNC(FRLEN(file-id)) 
FSEP  sets the token delimiters for the FGET function. %SYSFUNC(FSEP(file-id,cval)) 
FWRITE  writes a record to an external file. %SYSFUNC(FWRITE(file-id<,cc>)) 

------以上全部是关于外部文件的-----------------------------
GETOPTION  returns the value of a SAS system or graphics option. %SYSFUNC(GETOPTION(option-name<,reporting-options<,...>>)) 
--返回系统选项 options
GETVARC  assigns the value of a SAS data set variable to a character DATA step or macro variable. %SYSFUNC(GETVARC(data-set-id,var-num)) 
GETVARN  assigns the value of a SAS data set variable to a numeric DATA step or macro variable. %SYSFUNC(GETVARN(data-set-id,var-num)) 
LIBNAME  assigns or deassigns a libref for a SAS data library. %SYSFUNC(LIBNAME(libref<,SAS-data-library<,engine<,options>>>)) 
LIBREF  verifies that a libref has been assigned. %SYSFUNC(LIBREF(libref)) 
MOPEN  opens a directory member file. %SYSFUNC(MOPEN(directory-id,member-name<open-mode<,record-length<,record-format>>>)) 
NOTE  returns an observation ID for current observation of a SAS data set. %SYSFUNC(NOTE(data-set-id)) 
OPEN  opens a SAS data file. %SYSFUNC(OPEN(<data-file-name<,mode>>)) 
PATHNAME  returns the physical name of a SAS data library or an external file. %SYSFUNC(PATHNAME(fileref)) 
POINT  locates an observation identified by the NOTE function. %SYSFUNC(POINT(data-set-id,note-id)) 
REWIND  positions the data set pointer to beginning of a SAS data set. %SYSFUNC(REWIND(data-set-id)) 
SPEDIS  returns a number for the operation required to change an incorrect keyword in a WHERE clause to a correct keyword. %SYSFUNC(SPEDIS(query,keyword)) 
SYSGET  returns the value of the specified host environment variable. %SYSFUNC(sysget(host-variable)) 
SYSMSG  returns the error or warning message produced by the last function that attempted to access a data set or external file. %SYSFUNC(SYSMSG()) 
SYSRC  returns the system error number or exit status of the entry most recently called. %SYSFUNC(SYSRC()) 
-关于变量的信息------------
VARFMT  returns the format assigned to a data set variable. %SYSFUNC(VARFMT(data-set-id,var-num)) 
VARINFMT  returns the informat assigned to a data set variable. %SYSFUNC(VARINFMT(data-set-id,var-num)) 
VARLABEL  returns the label assigned to a data set variable. %SYSFUNC(VARLABEL(data-set-id,var-num)) 
VARLEN  returns the length of a data set variable. %SYSFUNC(VARLEN(datasetid,var-num)) 
VARNAME  returns the name of a data set variable. %SYSFUNC(VARNAME(data-set-id,var-num)) 
VARNUM  returns the number of a data set variable. %SYSFUNC(VARNUM(data-set-id,var-name)) 
VARTYPE  returns the data type of a data set variable. %SYSFUNC(VARTYPE(data-set-id,var-num)) 
  评论这张
 
阅读(8708)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017