boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - a SAS question for best solution
相关主题
请教一sas code
SAS菜鸟请教如果使SAS的output的结果放到一个文件内?
SAS SQL 问题
SAS question (urgent)
[合集] SAS里如何实现LOCF(LAST OBS CARRIED FORWARD)?
请教SAS问题
SAS base question
SAS DATA 求助
读入SAS data set的问题
问个SAS入门级的问题。。多谢。。
相关话题的讨论汇总
话题: sas话题: label话题: best话题: do话题: question
进入Statistics版参与讨论
1 (共1页)
z***9
发帖数: 1052
1
I have a practical SAS question. There are many solutions, but I am looking
for the best way to do it.
I have a character variable, ID, which has a lot of values and each value
has a lot of rows, for example, a,a,a,a,..b,b,b,b...c,c,c,c,c....... I want
assign a sequential number to each value, so all a will equal to 1, all b
will equal to 2.
I don't want to do a "if then" because there are too many values, what will
be the best way you can think of?
a*****3
发帖数: 601
2
上回我看见ooloo(还是精算?)用monotonic function , 每个group前面加个序号。 a
b c d就变成了 1 2 3 4.
可惜我学艺不精 细节都忘了.
l******n
发帖数: 9344
3
select distinct ID and create a value map, map the value back to ID

looking
want
will

【在 z***9 的大作中提到】
: I have a practical SAS question. There are many solutions, but I am looking
: for the best way to do it.
: I have a character variable, ID, which has a lot of values and each value
: has a lot of rows, for example, a,a,a,a,..b,b,b,b...c,c,c,c,c....... I want
: assign a sequential number to each value, so all a will equal to 1, all b
: will equal to 2.
: I don't want to do a "if then" because there are too many values, what will
: be the best way you can think of?

k*******a
发帖数: 772
4
order by ID
then by ID, if first.id then group+1
d******9
发帖数: 404
5
Try to use proc format--- invalue.
a*****3
发帖数: 601
6
人家变量太多, 不愿意手写 - 所以没法用 format

【在 d******9 的大作中提到】
: Try to use proc format--- invalue.
a*****3
发帖数: 601
7
方法不错 , 但听说monotonic最近比较流行.

【在 k*******a 的大作中提到】
: order by ID
: then by ID, if first.id then group+1

z***9
发帖数: 1052
8
this is the same method I can think of, I believe there might be better ways
to do, that's why I post the question here.

【在 l******n 的大作中提到】
: select distinct ID and create a value map, map the value back to ID
:
: looking
: want
: will

z***9
发帖数: 1052
9
it works. i think this is probably the easiest one. thanks a lot.

【在 k*******a 的大作中提到】
: order by ID
: then by ID, if first.id then group+1

g****8
发帖数: 2828
10
恩,如果,比code长短,这个方法应该是最优的

【在 z***9 的大作中提到】
: it works. i think this is probably the easiest one. thanks a lot.
l******n
发帖数: 9344
11
efficiency?
monitonic那个感觉会比较慢,如果data多

【在 g****8 的大作中提到】
: 恩,如果,比code长短,这个方法应该是最优的
p***r
发帖数: 920
12
try this code:
DATA FMT; SET LIBFMT.'DATASET$'N END=LAST;
RETAIN FMTNAME '$(FORMATNAME)' /**/'(FORMATNAME)' ;
START=;LABEL=;OUTPUT;

IF LAST THEN DO;

HLO='O'; LABEL='ZZ:UNIDENTIFIED';OUTPUT;


END;
KEEP FMTNAME START LABEL HLO;
RUN;
PROC FORMAT CNTLIN=FMT;RUN;
1 (共1页)
进入Statistics版参与讨论
相关主题
问个SAS入门级的问题。。多谢。。
[SAS] data set options (obs=) in output tables
help: proc logistic
请教SAS BASE 70题里的第35题
SAS code 问题
SAS question
求问SAS技术问题,one row to multiple row
a SAS question in base 70
SAS里怎么根据VALUE来选择需要OUTPUT的COLUMNS
请问SAS如何把put的内容输出到output窗口
相关话题的讨论汇总
话题: sas话题: label话题: best话题: do话题: question