由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS help
相关主题
SAS code 问题请教一个用SAS作DATA MERGE的问题
sas问题sas question
请教一个sas求和的问题ask SAS code
sas proc report的问题。工作中SAS问题 —另一个问题请教!
SAS code helpSAS 问题求助
求助:一个SAS小程序请教:get next record using BY group (SAS code data manipulation)
请问一个SAS proc sql的写法请教一sas code
help:data manipulationSAS questoin
相关话题的讨论汇总
话题: data话题: order话题: sas话题: mydata话题: proc
进入Statistics版参与讨论
1 (共1页)
l*******n
发帖数: 13
1
ASK:
How to use sas to get data B from data A?
That is, for each observation in B, I just need the order of the number at each level of A
Thanks
Data A
A B
1 1
1 1
1 3
1 3
1 5
1 23
2 4
2 4
2 6
2 6
2 12
2 22
Data B
A B
1 1
1 1
1 2
1 2
1 3
1 4
2 1
2 1
2 2
2 2
2 3
2 4
l*******n
发帖数: 13
2
In other words,
how to calculate the order of a numeric vector
(1 , 2, 2,5, 8,...)
to
(1, 2, 2, 3,4,...)
Doing this with R is a snap, but how with sas?
q**j
发帖数: 10612
3
proc rank.
l*******n
发帖数: 13
4
data mydata;
input A B;
datalines;
1 1
1 1
1 3
1 3
1 5
1 23
2 4
2 4
2 6
2 6
2 12
2 22
;
proc rank data=mydata out=results ties=low;
by A;
var B;
ranks NewB ;
run;
proc print data=results;
by A;
run;
BUT i got this, why?
q**j
发帖数: 10612
5
isn't it obvious?
l*******n
发帖数: 13
6
I do want to get the result like
1 1 2 2 3 3....
How to do that?
q**j
发帖数: 10612
7
remove redundant values, rank, merge back.
l*******n
发帖数: 13
8
it seems that SAS makes many things harder than expected.
I still feel afraid of using SAS even though I have many years of
programming experiences with java, c#,delphi,vb.net,php,r...
but what can we do if they do not go opensource?
D******n
发帖数: 2836
9
use R

【在 l*******n 的大作中提到】
: it seems that SAS makes many things harder than expected.
: I still feel afraid of using SAS even though I have many years of
: programming experiences with java, c#,delphi,vb.net,php,r...
: but what can we do if they do not go opensource?

o****o
发帖数: 8077
10
data mydata;
input A B;
datalines;
1 1
1 1
1 3
1 3
1 5
1 23
2 4
2 4
2 6
2 6
2 12
2 22
;
run;
proc freq data=mydata noprint order=internal;
table A*B/out=order(drop=COUNT PERCENT);
run;
data order;
set order; by A;
retain Order;
if first.A then Order=1; else Order+1;
run;
proc sql;
create table outdata as
select a.*, b.Order
from mydata as a join order as b
on a.A=b.A & a.B=b.B
order by a.A, a.B
;
quit;
相关主题
求助:一个SAS小程序请教一个用SAS作DATA MERGE的问题
请问一个SAS proc sql的写法sas question
help:data manipulationask SAS code
进入Statistics版参与讨论
l*******n
发帖数: 13
11
you rock!
how many years have you been using SAS? :)
m***6
发帖数: 884
12
What about just manually count?
data mydata;
input A B;
datalines;
1 1
1 1
1 3
1 3
1 5
1 23
2 4
2 4
2 6
2 6
2 12
2 22
;
run;
proc sort data = mydata; by A B; run;
data d; retain a b x; set mydata; by a b;
if _n_=1 then x=0; if first.b then x=x+1;
run;
l*******n
发帖数: 13
13
Nice try, but the result is not what I want.
Actually, There may exist several stratification variables A1 A2...
A1 A2 B...
x***x
发帖数: 3401
14
proc sort and followed by a data step utilizing _n_ variable
x**m
发帖数: 941
15
Full code:
proc sql;
create table seq as
select distinct a, b
from A
order by a, b;
run;
data seq2;
set seq;
by a b;
I+1;
if first.a then I=1;
run;
proc sql;
create table B as
select x.a, y.i
from A as x, seq2 as y
where x.a=y.a and x.b=y.b;
quit;
1 (共1页)
进入Statistics版参与讨论
相关主题
SAS questoinSAS code help
proc corr with very large data 计算结果有错求助:一个SAS小程序
请教这种freq 该用什么code算(sas)?Thanks!请问一个SAS proc sql的写法
神奇的proc meanshelp:data manipulation
SAS code 问题请教一个用SAS作DATA MERGE的问题
sas问题sas question
请教一个sas求和的问题ask SAS code
sas proc report的问题。工作中SAS问题 —另一个问题请教!
相关话题的讨论汇总
话题: data话题: order话题: sas话题: mydata话题: proc