关于本站
人大经济论坛-经管之家:分享大学、考研、论文、会计、留学、数据、经济学、金融学、管理学、统计学、博弈论、统计年鉴、行业分析包括等相关资源。
经管之家是国内活跃的在线教育咨询平台!
获取电子版《CDA一级教材》
完整电子版已上线CDA网校,累计已有10万+在读~ 教材严格按考试大纲编写,适合CDA考生备考,也适合业务及数据分析岗位的从业者提升自我。
TOP热门关键词
在诸如此类语句时。datathree;setonetwo;byvar;run;SAShelp中说明:Thevaluesofthevariablesin theprogramdatavectoraresettomissingeachtimeSASstartstoreadanewdatasetandwhentheBYgroupchanges. (SASlanguager ...
免费学术公开课,扫码加入![]() |
data three;
set one two;
by var;
run;
SAS help中说明:
The values of the variables in the program data vector are set to missing each time SAS starts to read a new
data set and when the BY group changes. (SASlanguage reference 9.2, P362)
但我经过测试,我发现其实除了首次将PDV置为缺失时,SAS开始读另一个data set和by 组改变时,均没有置为缺失。
以下是我的测试:
- data one;
- x=1;output;
- x=1;output;
- x=3 ;output;
- run;
- data two;
- x=2;output;
- x=2;output;
- x=4;output;
- run;
- proc sort data =one;
- by x;
- run;
- proc sort data=two;
- by x;
- data three;
- put "before set:" _all_;
- set one two;
- by x;
- put "after set:" _all_;
- run;
149put "before set:" _all_;
150 set one two;
151 by x;
152put "after set:" _all_;
153run;
before set:x=. FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=1
after set:x=1 FIRST.x=1 LAST.x=0 _ERROR_=0 _N_=1
before set:x=1 FIRST.x=1 LAST.x=0 _ERROR_=0 _N_=2
after set:x=1 FIRST.x=0 LAST.x=1 _ERROR_=0 _N_=2
before set:x=1 FIRST.x=0 LAST.x=1 _ERROR_=0 _N_=3
after set:x=2 FIRST.x=1 LAST.x=0 _ERROR_=0 _N_=3
before set:x=2 FIRST.x=1 LAST.x=0 _ERROR_=0 _N_=4
after set:x=2 FIRST.x=0 LAST.x=1 _ERROR_=0 _N_=4
before set:x=2 FIRST.x=0 LAST.x=1 _ERROR_=0 _N_=5
after set:x=3 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=5
before set:x=3 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=6
after set:x=4 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=6
before set:x=4 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=7
NOTE: There were 3 observations read from the data set WORK.ONE.
NOTE: There were 3 observations read from the data set WORK.TWO.
NOTE: The data set WORK.THREE has 6 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
标红部分都是by组改变,且要切换到另一个data set里读取观测。但是pdv里的值是retain的。没有置为missing.
同样,对于MERGE+by语句:
SAS HELP说明:
When SAS has read all observations in a
BY group from all data sets, it sets all variables in the program data vector
(except those created by SAS) to missing (SASlanguage reference 9.2, P373)
- data a;
- x=1; y='a1';output;
- x=2;y='a2';output;
- x=3 ;y='a3';output;
- run;
- data b;
- x=1;z='b1';output;
- x=2;z='b2';output;
- x=3;z='b3';output;
- run;
- proc sort data=one;
- by x;
- run;
- proc sort data=two;
- by x;
- run;
- data c;
- put "before set:" _all_;
- merge a b;
- by x;
- put "after set:" _all_;
- run;
198data c;
199put "before set:" _all_;
200 merge a b;
201 by x;
202put "after set:" _all_;
203run;
before set:x=. y=z=FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=1
after set:x=1 y=a1 z=b1 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=1
before set:x=1 y=a1 z=b1 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=2
after set:x=2 y=a2 z=b2 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=2
before set:x=2 y=a2 z=b2 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=3
after set:x=3 y=a3 z=b3 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=3
before set:x=3 y=a3 z=b3 FIRST.x=1 LAST.x=1 _ERROR_=0 _N_=4
NOTE: There were 3 observations read from the data set WORK.A.
NOTE: There were 3 observations read from the data set WORK.B.
NOTE: The data set WORK.C has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds 如上,标红部分也是by组change时,结果还是retain,没有置为Missing.
「经管之家」APP:经管人学习、答疑、交友,就上经管之家!
免流量费下载资料----在经管之家app可以下载论坛上的所有资源,并且不额外收取下载高峰期的论坛币。
涵盖所有经管领域的优秀内容----覆盖经济、管理、金融投资、计量统计、数据分析、国贸、财会等专业的学习宝库,各类资料应有尽有。
来自五湖四海的经管达人----已经有上千万的经管人来到这里,你可以找到任何学科方向、有共同话题的朋友。
经管之家(原人大经济论坛),跨越高校的围墙,带你走进经管知识的新世界。
扫描下方二维码下载并注册APP
免流量费下载资料----在经管之家app可以下载论坛上的所有资源,并且不额外收取下载高峰期的论坛币。
涵盖所有经管领域的优秀内容----覆盖经济、管理、金融投资、计量统计、数据分析、国贸、财会等专业的学习宝库,各类资料应有尽有。
来自五湖四海的经管达人----已经有上千万的经管人来到这里,你可以找到任何学科方向、有共同话题的朋友。
经管之家(原人大经济论坛),跨越高校的围墙,带你走进经管知识的新世界。
扫描下方二维码下载并注册APP
您可能感兴趣的文章
- SAS软件培训 ... | sas 9.2 第一步出错Microsoft Ru ...
- SAS软件培训 ... | SAS Global Forum: SAS 和Office ...
- SAS软件培训 ... | sas 9.2中修改ODS统计图形模板( ...
- SAS软件培训 ... | 《亲爱的翻译官》插曲《好过纠缠 ...
- SAS软件培训 ... | 不错的电子书:Saving.Time.and. ...
- SAS软件培训 ... | SAS 9.3 win8 64bit无法安装, 请 ...
- SAS软件培训 ... | 20120823--sas base 考试-94%--- ...
- SAS软件培训 ... | SAS公司CEO Jim Goodnight访谈
人气文章
本文标题:SAS help错了?关于set/merge +by语句中,pdv变量置为缺失的情况的讨论
本文链接网址:https://bbs.pinggu.org/jg/ruanjianpeixun_sasruanjianpeixun_2165331_1.html
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。



