楼主: dandan_9075
3493 27

[原创博文] 怎么让输出结果不留空 [推广有奖]

11
dandan_9075 在职认证  发表于 2012-5-10 17:16:19
pl172231 发表于 2012-5-8 23:59
你的数据集如果名字没搞错的话,就把我的代码跑一下,会生成一个叫kkk的数据集,你自己看
ods output su ...
谢谢 但是我运行不出来

12
dandan_9075 在职认证  发表于 2012-5-14 17:49:15
ntsean 发表于 2012-5-9 00:21
我来无聊一把

data test;
谢谢 这个可以哈

13
dandan_9075 在职认证  发表于 2012-5-14 22:05:35
ntsean 发表于 2012-5-9 00:21
我来无聊一把

data test;
这个程序我不怎么看的懂,请问一下,在data test2这一步,那个first.是什么意思?表示第一列?呵呵,因为我的变量要多很多,我想看看怎么应用?

14
sunset1986 发表于 2012-5-15 09:13:17
dandan_9075 发表于 2012-5-14 22:05
这个程序我不怎么看的懂,请问一下,在data test2这一步,那个first.是什么意思?表示第一列?呵呵,因为 ...
first.xxx表示xxx变量的第一行(first record or first observation)
An honest tale speeds best being plainly told.
Cheers!

15
sunset1986 发表于 2012-5-15 09:28:15
另外楼主,最后一步改为:
proc sort data=test1 out=test_new; by urban age descending y; run;应该就可以实现咯
An honest tale speeds best being plainly told.
Cheers!

16
sunset1986 发表于 2012-5-15 11:55:04
ntsean 发表于 2012-5-9 00:21
我来无聊一把

data test;
data test1;
  retain urbanr;
  set test;
  if urban ne . then urbanr=urban;
    else urban=urbanr;
  drop urbanr;
run;

赞这段程序
An honest tale speeds best being plainly told.
Cheers!

17
dandan_9075 在职认证  发表于 2012-5-15 23:53:11
sunset1986 发表于 2012-5-15 09:13
first.xxx表示xxx变量的第一行(first record or first observation)
谢谢

18
dandan_9075 在职认证  发表于 2012-5-15 23:55:33
sunset1986 发表于 2012-5-15 11:55
data test1;
  retain urbanr;
  set test;
请教一下 retain的用法
呵呵 对sas还不怎么了解 {:2_31:}

19
sunset1986 发表于 2012-5-16 09:01:36
首先呢,您先来研究一下这两个程序的区别,然后可能自己就figure out了,呵呵
简单的说,retain是帮助获取变量进行值的初始化和保留到下一个迭代步的作用
仔细观察log上面显示的区别

/*Without Retain*/
DATA WITHOUT_1;
PUT "Before the INPUT statement: " _ALL_;
INPUT X@@;
PUT "After the INPUT statement: " _ALL_ /;
DATALINES;
1 2 . 3
;

/*Without Retain*/
DATA WITH_1;
RETAIN X;
PUT "Before the INPUT statement: " _ALL_;
INPUT X @@;
PUT "After the INPUT statement: " _ALL_ /;
DATALINES;
1 2 . 3
;
An honest tale speeds best being plainly told.
Cheers!

20
sunset1986 发表于 2012-5-16 09:11:12
当楼主研究清楚上面两个程序的区别后,再来运行一下下面这个程序,我把它分段化执行了,注意看log,然后琢磨一下retain是如何巧妙的补足missing value的:
data with_2 (drop=urbanr);
        retain urbanr;
        put "before input: " _all_;
        input urban age y;
        if urban ne . then urbanr=urban;
    else urban=urbanr;
        put "after assignment: " _all_ /;
datalines;
1 4 6
. 5 2
. 1 60
. 2 7
. 3 3
2 2 4
. 3 9
3 3 20
. 4 2
. 2 1
;
run;
An honest tale speeds best being plainly told.
Cheers!

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

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