多说几句:
[color=blue:8ca52]1/ VAR**系列函数为data set I/O functions是SASV7/8+以后增加的,但实际上SCL很早就有了,所以应该说data set I/O functions是从SCL借到SAS/BASE去的。看上面的写法是何等与SCL相似(rc=...).
2/ 当然student的写法也是data set I/O functions应用的另外一种方式,和BASE语句相似,可否说是这些fuctions从SCL搬进BASE后的入乡随俗的表现?
3/ V**系列函数则为Variable Information fuctions,是SASV7/8+以后增加的,有点效仿上述I/O函数,工作的对象为变量的属性(name, length等)。
zibao的解答非常精彩,佩服!今后还请多多指教。作者: shiyiming 时间: 2003-10-30 10:23 标题: 新问题 如何将数据集所有的变量提取出来组成一个串呢;作者: shiyiming 时间: 2003-10-30 16:51
/* MACRO varlist: Gets the names of the numerical , dateformat and character variables
from a dataset and writes them to macro variables.
Input: Data_in = Name of input dataset
Outputs: numlist = Macro variable of numerical variable names
datelist = Macro variable of dateformat variable names
charlist = Macro variable of character variable names
*/
%MACRO varlist(DATA_IN);
%global numlist datelist charlist;
* Get Contents;
proc contents data=&data_in out=temp1 noprint;
run;
*Create data set nums that contains only the names of the numerical but not date vbles;
data nums(keep=name label);
set temp1(keep=name type label format);
if type=1 and format ne 'DATE';
run;
* Put each name in a macro vble, get number of vbles;
data _null_;
set nums;
call symput('NN'||left(put(_n_,10.)),left(put(name,$9.)));
call symput('numnums',_n_);
run;
* Concatenate the vble names;
%do i=1 %to &numnums;
%if &i=1 %then %let numlist = &&NN&i;
%else %let numlist = &numlist &&NN&i;
%end;
%put => The list of numerical vbles is: &numlist;
*Create data set nums that contains only the names of the date vbles;
data dats(keep=name label);
set temp1(keep=name type label format);
if type=1 and format eq 'DATE';
run;
* Put each name in a macro vble, get number of vbles;
data _null_;
set dats;
call symput('DD'||left(put(_n_,10.)),left(put(name,$9.)));
call symput('numdats',_n_);
run;
* Concatenate the vble names;
%do i=1 %to &numdats;
%if &i=1 %then %let datelist = &&DD&i;
%else %let &datelist = &datelist &&DD&i;
%end;
%put => The list of date format vbles is: &datelist;
*Create data set chars that contains only the names of the char vbles;
data chars(keep=name label);
set temp1(keep=name type label);
if type=2;
run;
* Put each name in a macro vble, get number of vbles;
data _null_;
set chars;
call symput('DD'||left(put(_n_,10.)),left(put(name,$9.)));
call symput('numchars',_n_);
run;
* Concatenate the vble names;
%do i=1 %to &numchars;
%if &i=1 %then %let charlist = &&DD&i;
%else %let charlist = &charlist &&DD&i;
%end;
%put => The list of character vbles is: &charlist;
%MEND varlist;作者: shiyiming 时间: 2003-10-30 18:11
proc sql noprint;
select name into:str separated by ',' from sashelp.vcolumn
where libname="SASHELP" and memname="CLASS";
quit;