全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3324 5
2012-01-13
libname chapt3 'f:\data_model\book_data\chapt3';
data percent;
    if _n_ = 1 then
        set chapt3.summary(keep = cargosum);
    set chapt3.empcount;
    pctemps = numemps / cargosum;
run;
一共分配两个指针,第一条指向数据集summary,第二条指向数据集empcount,
keep语句使得在读入PDV时只读入cargosum这个变量

个人疑问:为什么percentcargosum变量的第二条到最后一条观测数的值不是缺失值??

两个数据集如下:



二维码

扫码加我 拉你入群

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

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

全部回复
2012-1-13 11:07:22
Sorry, we couldn't find your data sets.
二维码

扫码加我 拉你入群

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

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

2012-1-13 11:13:31
由于你用条件语句if _n_=1读取summary数据集,PDV的cargosum变量保留summary第一个观测对应的值,数据步第二次迭代时,cargosum变量值没有被改写,它的值在PDV中不变化,故第二至末尾观测的cargosum变量值不是缺失值。
二维码

扫码加我 拉你入群

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

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

2012-1-13 11:16:29
我快崩溃了。 图片一直添加不成功,可能是网速问题。
二维码

扫码加我 拉你入群

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

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

2012-1-13 11:21:26
set语句读取时只有第一次会初始化为缺失值,以后就不会再初始化为缺失值了
二维码

扫码加我 拉你入群

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

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

2012-1-13 11:24:45
when _n_ = 1, SAS puts both of "cargosum" and "numemps" from "chapt3.summary" and "chapt3.empcount" into PDV, so we get the first "pctemps".
Then _n_ = 2, SAS finds a new observation from "chapt3.empcount" and puts it into PDV. But your statement, "if _n_ = 1", guarantees no new observations could be read from "chapt3.summary". So the first observation of "chapt3.summary" just stay in its PDV.
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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