楼主: 若水烟寒
3897 17

连续使用两个set之后的结果 [推广有奖]

  • 3关注
  • 9粉丝

已卖:840份资源

博士生

8%

还不是VIP/贵宾

-

威望
0
论坛币
1391 个
通用积分
33.0863
学术水平
14 点
热心指数
18 点
信用等级
12 点
经验
2716 点
帖子
183
精华
0
在线时间
176 小时
注册时间
2011-5-11
最后登录
2025-6-4

楼主
若水烟寒 发表于 2012-11-11 20:58:02 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
data one;
input x y$;
cards;
1 Groucho
3 Harpo
3 Kart
;
data two;
input x z$;
cards;
2 Chico
4 Zeppo
;
data three;
set one;
set two;
run;
proc print data=three;
run;

连续用两个set之后结果输出十分奇怪……                                                    Obs    x       y         z                                                    1     2    Groucho    Chico                                                    2     4    Harpo      Zepposet的编译和执行原理是怎样的呢?是不是后一次的会覆盖上一次的结果?


二维码

扫码加我 拉你入群

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

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

关键词:Set cards Three Input print one 连续

回帖推荐

davil2000 发表于2楼  查看完整内容

In data loop 1(_N_=1): x=1 y=Groucho z= _ERROR_=0 _N_=1 x=2 y=Groucho z=Chico _ERROR_=0 _N_=1 In data loop 2(_N_=2): x=3 y=Harpo z=Chico _ERROR_=0 _N_=2 x=4 y=Harpo z=Zeppo _ERROR_=0 _N_=2 In data loop 3(_N_=3): x=3 y=Kart z=Zeppo _ERROR_=0 _N_=3
已有 1 人评分经验 学术水平 热心指数 信用等级 收起 理由
数据分析师3K + 60 + 1 + 1 + 1 good question

总评分: 经验 + 60  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

本帖被以下文库推荐

沙发
davil2000 发表于 2012-11-11 21:11:33
In data loop 1(_N_=1):
x=1 y=Groucho z=  _ERROR_=0 _N_=1
x=2 y=Groucho z=Chico _ERROR_=0 _N_=1
In data loop 2(_N_=2):
x=3 y=Harpo z=Chico _ERROR_=0 _N_=2
x=4 y=Harpo z=Zeppo _ERROR_=0 _N_=2
In data loop 3(_N_=3):
x=3 y=Kart z=Zeppo _ERROR_=0 _N_=3
R是万能的,SAS是不可战胜的!

藤椅
davil2000 发表于 2012-11-11 21:12:08
data three;
set one;
put _all_;
set two;
put _all_;
run;
R是万能的,SAS是不可战胜的!

板凳
davil2000 发表于 2012-11-11 21:14:09
In every loop, the variable's value will be replaced by the non-default new value.
R是万能的,SAS是不可战胜的!

报纸
若水烟寒 发表于 2012-11-11 21:40:06
davil2000 发表于 2012-11-11 21:14
In every loop, the variable's value will be replaced by the non-default new value.
Thank you~but it seems that the data loop 3 won't do because the pointer will stop after reading the obs 2 in the dataset two. The print result also presents only two obs.....

地板
davil2000 发表于 2012-11-12 08:21:26
若水烟寒 发表于 2012-11-11 21:40
Thank you~but it seems that the data loop 3 won't do because the pointer will stop after reading t ...
data three;
set one;
put _all_;
output;
set two;
put _all_;
output;
run;
proc print ;
run;

The results will be as follows:

Obs    x    y            z

1     1    Groucho
2     2    Groucho    Chico
3     3    Harpo      Chico
4     4    Harpo      Zeppo
5     3    Kart       Zeppo

已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
数据分析师3K + 20 + 2 + 2 + 2 热心帮助其他会员

总评分: 论坛币 + 20  学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

R是万能的,SAS是不可战胜的!

7
davil2000 发表于 2012-11-12 08:24:07
data three;
set one;
put _all_;
output;
set two;
put _all_;
/*output;*/
run;
proc print ;
run;

The results will be as follows:


Obs    x    y            z

  1     1    Groucho
  2     3    Harpo      Chico
  3     3    Kart       Zeppo
R是万能的,SAS是不可战胜的!

8
davil2000 发表于 2012-11-12 08:27:42
data three;
put _all_;
set one;
put _all_;
/*output;*/
set two;
put _all_;
output;  /*This is always an implicit statement when there is no same statement ahead*/
run;
proc print ;
run;

the resulsts will be as follows:

Obs    x       y         z

1     2    Groucho    Chico
2     4    Harpo      Zeppo

For data set two, there exist no obs corresponding to _N_=3.  the data loop will leave out here. so the results will be only 2 obs.
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
数据分析师3K + 100 + 100 + 5 + 5 + 5 分析的有道理

总评分: 经验 + 100  论坛币 + 100  学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

R是万能的,SAS是不可战胜的!

9
davil2000 发表于 2012-11-12 08:30:00
By default, every DATA step contains an implicit OUTPUT statement at the end of each iteration that tells SAS to write observations to the data set or data sets that are being created.

Placing an explicit OUTPUT statement in a DATA step overrides the automatic output, and SAS adds an observation to a data set only when an explicit OUTPUT statement is executed.

Once you use an OUTPUT statement to write an observation to any one data set, however, there is no implicit OUTPUT statement at the end of the DATA step. In this situation, a DATA step writes an observation to a data set only when an explicit OUTPUT executes.

You can use the OUTPUT statement alone or as part of an IF-THEN or SELECT statement or in DO-loop processing.
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
若水烟寒 + 1 + 1 + 1 分析的有道理

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

R是万能的,SAS是不可战胜的!

10
cufering 发表于 2012-11-12 08:39:08
进来学习下
个人网站:全站用SAS搭建而成,邮编无忧网,网址是http://www.51youbian.com

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-7 11:57