全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2532 8
2010-04-25
大家好,请教个问题啊,就是关于set的 请看data a6部分。麻烦大家运行一下看看能不能运行,顺便问一下在哪个版本下能运行,谢谢了。
*注:我的是8.2的运行时报错,但我朋友的9.2 的能运行,所以我想问下都在哪个版本下能运行。
data a1;
input id ;
cards;
1
;
run;
data a2;
input id ;
cards;
2
;
run;
data a3;
input id ;
cards;
3
;
run;
data a4;
input id ;
cards;
4
;
run;
data a5;
input id ;
cards;
5
;
run;
data a6;
set a1-a5;
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-4-25 19:54:18
Using Data Set Lists with SET
You can use data set lists with the SET statement. Data set lists provide a quick way to reference existing groups of data sets. These data set lists must be either name prefix lists or numbered range lists.

Name prefix lists refer to all data sets that begin with a specified character string. For example, set SALES1:; tells SAS to read all data sets starting with "SALES1" such as SALES1, SALES10, SALES11, and SALES12.

Numbered range lists require you to have a series of data sets with the same name, except for the last character or characters, which are consecutive numbers. In a numbered range list, you can begin with any number and end with any number. For example, these lists refer to the same data sets:

sales1 sales2 sales3 sales4

sales1-sales4

Note:   If the numeric suffix of the first data set name contains leading zeros, the number of digits in the numeric suffix of the last data set name must be greater than or equal to the number of digits in the first data set name; otherwise, an error will occur. For example, the data set lists sales001-sales99 and sales01-sales9 will cause an error. The data set list sales001-sales999 is valid. If the numeric suffix of the first data set name does not contain leading zeros, the number of digits in the numeric suffix of the first and last data set names do not have to be equal. For example, the data set list sales1-sales999 is valid.  

Some other rules to consider when using numbered data set lists are as follows:

You can specify groups of ranges.

set cost1-cost4 cost11-cost14 cost21-cost24;
You can mix numbered range lists with name prefix lists.

set cost1-cost4 cost2: cost33-37;
You can mix single data sets with data set lists.

set cost1 cost10-cost20 cost30;
Quotation marks around data set lists are ignored.

/* these two lines are the same */
set sales1 - sales4;
set 'sales1'n - 'sales4'n;
Spaces in data set names are invalid. If quotation marks are used, trailing blanks are ignored.

/* blanks in these statements will cause errors */
set sales 1 - sales 4;
set 'sales 1'n - 'sales 4'n;

/* trailing blanks in this statement will be ignored */
set 'sales1   'n - 'sales4   'n;
The maximum numeric suffix is 2147483647.

/* this suffix will cause an error */
set prod2000000000-prod2934850239;
Physical pathnames are not allowed.

/* physical pathnames will cause an error */
&let work_path = %sysfunc(pathname(WORK));
set "&work_path\dept.sas7bdat";
这个是SAS HELP里面的解释
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-4-25 19:55:13
%macro output;
data a6;
     set %do i=1 %to 5;
        a&i
        %end;
        ;
run;
%mend;
%output;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-4-25 20:50:07
我以为是matlab呢。呵呵原来不是
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-4-25 21:22:10
xiaosanmao 发表于 2010-4-25 19:55
%macro output;
data a6;
     set %do i=1 %to 5;
        a&i
        %end;
        ;
run;
%mend;
%output;
In this case, using (set a1-a5) is better.

64   data a6;
65   set a1-a5;
66   run;

NOTE: There were 1 observations read from the data set WORK.A1.
NOTE: There were 1 observations read from the data set WORK.A2.
NOTE: There were 1 observations read from the data set WORK.A3.
NOTE: There were 1 observations read from the data set WORK.A4.
NOTE: There were 1 observations read from the data set WORK.A5.
NOTE: The data set WORK.A6 has 5 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-4-26 08:42:52
5# bobguy
能问一下您的SAS版本是哪个吗?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群