由买买提看人间百态

topics

全部话题 - 话题: obs
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
Y**********8
发帖数: 67
1
来自主题: Statistics版 - 请教SAS BASE的一个题目
同意
执行第一个input语句,input style就已经把所有obs读入了
假如在if..then..之后加个:else delete 估计会筛选出特定style的obs

observations.
Y**********8
发帖数: 67
2
来自主题: Statistics版 - SAS base 123 question 38 疑问
每个obs经过"do...end..."这个循环,会变成5个obs,分别对应2000,2005,2010,
2015和2010年
5×5不就是25
G**S
发帖数: 1108
3
来自主题: Statistics版 - 问个SAS的问题
用proc sql怎么往一个table后面插入一个新的obs?
我的做法是手动产生一个只有新obs的table然后union,可是面试官好像不太认同,有
没有大虾有更
好的解决方案?谢谢。
o******6
发帖数: 538
4
来自主题: Statistics版 - [合集] 请教sas base 123中几题
☆─────────────────────────────────────☆
jessie31 (jessie024) 于 (Sun Mar 1 01:01:56 2009) 提到:
16 data work.empsalary;
set work.people(in=inemp);
work.money(in=insal);
if insal and inemp;
run;
The data set work.people has 5 obs, and the data set work.money has 7
observations.
How many obs will the data set work.empsalary contain?
A.0
B.5
C.7
D.12
Why the answer is A.
The default value for inemp and insal is 0?
73.
data work.test;
First='Ipswich, England';
City_Country=substr(Firs
l***a
发帖数: 12410
5
来自主题: Statistics版 - how do you deal with sparse data?
for example, 1000 obs, 50 good and 1950 bad.
if you directly run logistic model on the data, the predictive ability for
good obs is very weak.
besides taking only a small portion of bad to combine with good to build the
model, any other good ideas?
S******y
发帖数: 1123
6
来自主题: Statistics版 - How to get rid of loop in R code?
I have a sorted data in R. I am trying to cut tiles/deciles based on
cumulative weights.
My code is below -- but how can I get rid of this loop (which might not be a
good coding practice here) ?
Thanks.
#------------------------------------------
#dat - R data frame (already sorted by variable of interest)
#n - number of obs
#tile - a vector of length n showing which tile the obs belongs to
#n_tile - number of tiles (i.e. deciles if it is 10)
#--------------------------------------
#R code --
p*****o
发帖数: 543
7
来自主题: Statistics版 - 问个SAS数据处理的问题
Thanks a lot.
I just got it done with a stupid way....
I transposed each data set and created a new variable for each one obs = _n_
and then merge them by obs and then transpose back....
D******n
发帖数: 2836
8
because sas didnt intend to have any logic in the first place, its logic was
just line by line processing. As more and more ppl used SAS and ppl asked f
or more and more functionalities , SAS developers just keep adding those wei
rd syntax/logic to SAS, just like patches.
one example is , you have firstobs in data step, but you dont have lastobs,
because obs= is it!
Why? because SAS developers first added obs=, as users wanted to print first
couple of lines, and then ppl wanted to get started no
o****o
发帖数: 8077
9
来自主题: Statistics版 - An interesting question from mysas.net/forum
my general idea is :
this can be solved using hash list while your obs are index by the four IDs
SEPARATELY.
by OP's description, as searching goes on, any subsequent observation that
has 2 IDs in the current combination of id pool will be identified as
belonging to the same group, then any new ID will be added to the pool. The
main hash table contains the record number which is the unqiue ID for each
obs, and the other elements in the hash is an 5 auxilary hash lists, 4 for
id pool of each ID#
x**********t
发帖数: 45
10
题目是这样子的:
The sasdata.banks data set has five obs when the following SAS program is
submitted:
libnamesasdata 'SAS-date-library';
data allobs;
set sasdata.banks;
capital=0;
do year=2000 to 2020 by 5;
capital+((capital+2000)*rate);
output;
end;run;
proc print data=allobs;run;
How many observations will the ALLOBS data set contain?
结果是25,一头雾水啊。题目没有给sasdata.banks是个啥,这样怎么能知道allobs有
多少个呢?我怎么看都觉得是5个obs
谢谢大家指教!!
s********e
发帖数: 323
11
来自主题: Statistics版 - 也问几道SAS base 题目
Thanks a lot.
But I am still a little confused. For Question #2, after I read your
explaination, I understand why there are 5 obs in ONE and TWO, but why there
is 3 obs in OTHER?

sets
y*********s
发帖数: 24
12
来自主题: Statistics版 - 请教怎么样转置?
我有个SAS 数据, 1个OBS, 30个VAR,
如何把它变成30个OBS, 和1 个VAR?
请教高手, 谢谢!
n*****s
发帖数: 10232
13
来自主题: Statistics版 - how to test if two groups are same?
看了些TOST equivalence test的资料,感觉有两个问题
1)这样的test没有充分利用paired obs的信息
2)这个test处理超过1m obs的case会不会还是太sensitive
T*k
发帖数: 398
14
来自主题: Statistics版 - large dataset impot into SAS
proc print data=xxx (obs=500);
run;
Add (obs=500) and try again.
D******n
发帖数: 2836
15
来自主题: Statistics版 - 海量SAS data的处理
fts,这跟sampling啥关系啊。
难道我要找出所有var1==1的obs的obs number, 我还可以去sampling?
u****n
发帖数: 9
16
来自主题: Statistics版 - 请教SAS BASE 70题里的第35题
sasuser.two 有5个obs
5 2
5 2
3 1
3 1
5 6
sas 是碰到output就会输入到data set里,所以if下面的output那条会把那3个obs直接
输入到sasuser.one,sasuer.two,others里面。
然后你在看if语句,满足条件的在输入到各自的data set。
D******n
发帖数: 2836
17
来自主题: Statistics版 - 如何判断一个dataset是不是空的?
很可惜這種辦法用在數有where clause的dataset的obs是最慢的。
我做了一個小測試。一個1.8million的data set. 數當var1>40時的obs的數量。分別用
了,
sql,data step,還有下面那個用file handle的方法,運行時間(秒)如下:
real_time cpu_time
sql 53 34
data 86 107
file 188 182
p******r
发帖数: 1279
18
请教大家,我碰到一个问题,dependent variable是一个0 1 2 3...9共10个的
categorical variable,现在我要对其做 ordinal regression。
但问题是这个dependent variable 严重skewed,1200多个obs大多集中在0,1,2, 在
9那里只有可怜的1个obs,请问这种情况还能做ordinal regression不?如果不能做,
那要怎么办呢?
N****n
发帖数: 1208
19
来自主题: Statistics版 - 哪位用R做过CART MODEL
谢谢!试了,但XTEST 如果和 XTRAIN 数量不等的时候,怎么写都出错。
比如我用100个OBS来FIT MODEL,另预测20个新来的OBS,一用PREDICT方程就出错,搞
不定。
是我哪地方FIT错了,还是不应该用predict function?
A*******s
发帖数: 3942
20
不知道大牛们有啥decent一点的做法
我的比较笨的方法是用point=
do i=1 to obs1;
set ds1 point=i obs=obs1;
do j=1 to obs2;
set ds2 point=j obs=obs2;
end;
end;
h***0
发帖数: 312
21
来自主题: Statistics版 - 新手请SAS合并数据集问题
我现在有03到07五年的SAS数据集,每个都包括几千个obs和variables。
现在我把5个datasets全都放在一起了,用下面的语句:
data ds0307;
set newlib.fall03 newlib.fall04 newlib.fall05 newlib.fall06 newlib.fall07;
by ID;
然后我打开ds0307发现有的数据只有3年或4年的obs.怎么把那些不足5年的数据去掉啊?
谢谢!
p**5
发帖数: 2544
22
obs=5 是不是读取5个obs?
datarow = 5 ?
a***r
发帖数: 420
23
我的意思是,比如有两个dataset,分别是某实验before和after的各种数值
dataset1:
obs var1.1 var1.2 var1.3 var1.4...
1 2 3 3 2
2 1 2 2 2
......
dataset2:
obs var2.1 var2.2 var2.3 var2.4...
1 5 2 3 5
2 4 2 2 4
...
我想求var1.1-var2.1; var1.2-var2.2...的R2
最后存在一个新的dataset里
我初步的想法是把两个dataset合起来成,叫它comb,
然后proc corr data=comb out=out; _numeric_;
然后在out里选取和保留var1.1-var2.1...这样的组合
可是感觉这样很浪费空间啊?
不知大家有没有什么更好的建议?
比如,用macro直接只算需要的组合,可是这样我不知道如何把所有R2合到一个dat... 阅读全帖
f*****k
发帖数: 110
24
来自主题: Statistics版 - SAS中FORMAT问题求教
有这样一个dataset:
OBS GENDER WEIGHT . . . . .
1 1 1 . . . . .
2 2 2 . . . . .
3 3 3 . . . . .
. . . . . . . .
. . . . . . . .
当在SAS中打开这个dataset时,由于有permanent format的存在,显示的是这样的:
OBS GENDER WEIGHT . . . . .
1 male NA . . . . .
2 female low . . . . .
3 NA high . . . . .
. . . . . . . .
. . . . . . . .
我有两个与FORMAT有关的问题需要解决。一个就是如何让这个dataset在SAS中显示原本
的数字,而不是数字的value label。
另外一个问题就是如何把'NA'所对应的... 阅读全帖
h********o
发帖数: 103
25
来自主题: Statistics版 - sas 变量赋值问题
Try this:
==========================
DATA TEST;
INPUT OBS @@;
CARDS;
1 2 3 1 2 3 4 5 1 2 1 2 3 4 1 2 3 4 5 6 7 8 9
;
DATA TEST (DROP = CHAR INDEX);
CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
SET TEST;
IF OBS = 1 THEN INDEX + 1;
GROUP = SUBSTR(CHAR,INDEX,1);
RUN;
k*******a
发帖数: 772
26
来自主题: Statistics版 - 求教 SAS base 123 Q 16
也不是,有可能会是12
比如 data1里面有12个obs, 都是1
data2里面有5个obs,也都是1
按照里面那个merge的话,结果就是12个1

于5
s*********y
发帖数: 34
27
来自主题: Statistics版 - 询问一个SAS数据处理问题
原数据:
Obs ID name usage GC x y
1 9 I 5.2 . 27 0
2 1 A 5.6 . 24 0
3 14 N 5.9 . 8 0
4 5 E 6.0 . 70 1
5 2 B 6.5 . 77 1
6 10 J 6.8 . ... 阅读全帖
t******m
发帖数: 58
28
郁闷了。。楼上2为大虾的办法我之前都尝试过,都不行,sex都是missing的。我现在
贴点code出来,恳请大虾继续指点。。。
OPTIONS LS=132 PS=10000 NOCENTER;
/*
Fromat
DIN=DIN
CD=Claim Date
DS=Days Supply
NU=Number of Units
UP=UNIT_PRICE
ICP=Ingredient Cost Paid
DFP=Dispensing Fee Paid
TAP=Total Amount Paid
RPS=Random Pharmacy Store
RPN=Random Patient Number
PDOB=Patient DOB
PG=Patient Gender
*/
data f1;
/*INFORMAT CD YYMMDD13.2; FORMAT CD YYMMDD10.;
INFORMAT PDOB YYMMDD13.2; FORMAT PDOB YYMMDD10.;*/
INFORMAT UP ICP DFP TAP DOLLAR7.2; FORMAT UP ICP DFP... 阅读全帖
D*D
发帖数: 236
29
来自主题: Statistics版 - 求教一个简单的data step 牛肉包
想要把一个sorted dataset里,每个subgroup的前三observation输出。
test code 如下
data temp;
do i = 1 to 5;
do j = 1 to 5;
output;
end;
end;
run;
proc sort data = temp; by i j; run;
data new;
set temp;
by i;
if first.i then do;
do k = 1 to 3;
set temp;
by i;
output;
end;
end;
run;
proc print data = new;
run;
结果是
Obs i j k
1 1 1 1
... 阅读全帖
D*D
发帖数: 236
30
来自主题: Statistics版 - 求教一个简单的data step 牛肉包
Thanks for the explanation here. It really helps.
The code you modified was not right though. It printed the same combination
of i and j for 3 times.
What I was looking for was to output the first 3 obs of j, that is j = 1, 2
and 3.
I came to the following code which does the job. Thanks for the discussion.
I have a better understanding of data step now.
data temp;
do i = 1 to 5;
do j = 1 to 5;
output;
end;
end;
run;
proc sort data = temp; by i j; run;
data new (drop = t);
retain t;
set... 阅读全帖
s********e
发帖数: 68
31
obs var1 var2 var3
1 a1 b1 2001.1.3
2 a1 b2 2001.2.4
3 a1 b3 2001.2.4
4 a2 b4 2009.10.20
5 a2 b5 2009.10.21
6 a2 b6 2009.12.3
7 a2 b7 2009.11.5
1个var1对应3个或者是四个var2,var2的生产日期为var3,我需要在var1下,比较var3
,就是日期,如果日期是同一天(如obs2,obs3)或是日期差距小于3天(如obs4和
obs5), 那么就label出来,并且删除。得到的结果期望是
obs var1 var2 var3
1 a1 b1 2001.1.3
6 a2 b6 2009.12.3
7 a2 b7 2009.11.5
请问应该怎么做呢?
d******9
发帖数: 404
32
来自主题: Statistics版 - #SAS BASE 问题,明天就考试了##
Yes, you are right.
data test;
Author='Agatha Christie';
A=scan(author, 1,' ,');
First=substr(scan(author, 1,' ,'),1,1);
L1=length(A);
L2=length(first);
run;
proc print;
run;
SAS Output:
Obs Author A First L1 L2
1 Agatha Christie Agatha A 6 1
When we use lengthc, the results are different:
data test;
Author='Agatha Christie';
A=scan(author, 1,' ,');
First=substr(scan(author, 1,' ,'),1,1);
L1=lengthc(A);
L2=lengthc(first);
run;
Obs ... 阅读全帖
D******n
发帖数: 2836
33
我也来参与R与SAS大讨论。
我以前也是狂骂sas的,现在觉得SAS跟很多busniess还是衔接的很好。起码对于我们这
个行业。
这体现在SAS的datastep和方便的输出。这在R上面就很是蹩脚。有时候不是能不能做的
问题。
理论上你用perl做也可以,就看谁更自然和直接。
我之前也说过,SAS的data step很多恶心的东西都是跟它的基本数据逻辑分不开的。就
是行操作,一个obs一个obs的进行数据处理,这导致了很多列操作非常别扭。但是很多
天然数据就是这个样子(起码我们行业),所以这个处理方式很自然也很顺畅。有时候
你觉得R就可以很方便做到的东西,SAS里面就很难,可是细想,最终
所花的运行时间和算法复杂度可能是一样的。
R相比之下就很令人失望,麻烦的debug,不统一的packages,大数据崩溃问题。感觉上
在干净而小的数据上
做做prototype,测试一下fancy ideas还不错,其他真是很没谱。
e****e
发帖数: 50
34
来自主题: Statistics版 - 大牛请进,问个sas问题
最近遇到个sas问题,太弱啦,不知道怎么破解,请版上大牛们指点下:
一个obs〉10,000的dataset,有两个fields,一个是clientcode,一个是value。
clientcode有时是重复的,就是说同一个client会被输入系统不止一次。大概有一大半
的clientcode是重复两三次的,一小半的只有一次。
现在要把所有相同的clientcode的obs的value加起来,使每个clientcode在
database里只出现一次。想了半天没想出解法,求大家帮忙想想。
k****i
发帖数: 347
35
来自主题: Statistics版 - 包子问,SAS里data long to wide format
如果data在long format下是每个人有多行observation,但是# of obs并不固定
比如第一个人50行,第二个人33行,第三个人42行。。。
variable数目很大(>100),x1, x2, x3 ...
这种情况下想转换成wide format,也就是每人只有一行,但是variable要transpose成
x1_1, x1_2, x1_3, ... x1_n, x2_1, x2_2, x2_3, ... x2_n, x3_1, x3_2, x3_3, ..
. x3_n
似乎一般的data step long to wide format办法不行(因为每个人# of obs不固定会
导致out of range error?)
求可运行的sas macro/code
v********9
发帖数: 35
36
来自主题: Statistics版 - 如何把一个变量分割成两个
merge test(rename=(v1=Var1) firstobs=1 obs=3)
test(rename=(v1=Var2) firstobs=4 obs=6) ;
S********s
发帖数: 42
37
来自主题: Statistics版 - Help for beginner of Macro
I am trying to learn Macro, and I ran the code blew to generate random
numbers. But I did not get any output and I tried other codes too, no output
neither. Is it means my SAS does not work or I did not turn on some options
. The log display exactly the same contents as the codes.
%macro gen(n,start,end);
data generate;
do Subj=1to &n;
x=int((&end-&start+1)*ranuni(0)+&start);
output;
end;
run;
proc print data=generate noobs;
title "Randomly Generated Data set with &n o... 阅读全帖
t******g
发帖数: 372
38
来自主题: Statistics版 - 关于在R中对字符数组进行比较
1> data(iris)
1> str(iris)
'data.frame': 150 obs. of 5 variables:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
$ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
$ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
$ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1
...
1> identical(as.character(iris), as.vector(iris, mod='character'))
[1] TRUE
1> identical(as.charac... 阅读全帖
j******o
发帖数: 127
39
来自主题: Statistics版 - sas大牛们这个要怎么实现呀
data c;
if _n_=1 then do;
set b (rename=(nu=nu1 ran=ran1) firstobs=1 obs=1);
set b (rename=(nu=nu2 ran=ran2) firstobs=2 obs=2);
end;
set a;
run;
b******s
发帖数: 345
40
现在的dataset是这样的,是一个sampling后的输出(即使同一个ID重复后其famid1是不
同的):
obs ID famid famid1
1 1002 2 1
2 1003 3 2
3 1003 3 3
4 1010 10 4
5 1044 37 5
6 1044 37 6
7 1089 49 7
想得到的是这样的:
9020和9080是与1010及1044相应的twins,9020和9080(twins信息)加在每一个的1010
及1044的后面,并且与每一个1010及1044的famid1相同。
obs ID famid famid1
1 1002 2 1
2 1003 3 2
3 1003 3 3
4 1010 10 4
5 9020 10 4
6 1044 37 5
7 9080 37 5
8 1044 ... 阅读全帖
s********1
发帖数: 54
41
Compare data inf123 and data inf, who can explain to me why outputs from
these two codes are not the same? Data inf is the right one. In terms of the
difference, they are represented as follows:
In data inf123
length readd $10.;/*先把長度都開好*/
input group id_n name $ job $12. st_time $10.;
In data inf
length job $12 readd $10 st_time $10;/*先把長度都開好*/
input group id_n name $ job $ st_time $;
______________________________________________
data inf123 ;
length readd $10.;/*先把長度都開好*/
... 阅读全帖
l******9
发帖数: 48
42
来自主题: Statistics版 - 请教SAS 123题中的17, 57, 68, 72题
17题,不知道是不是排版问题,我觉得Dan 37000这个obs应该是在salary这个dataset
里,这样才会有四个obs。
57题,给variable赋值一定是分开的语句,不能用and同时给两个variable赋值。
68题,if last.department 这后面应该是省了一个 then output是可以不写出来的。
这个我是猜的,不然这个语句总觉得没说完。
72题,B选项的Ipswich前面有个空格。这题应该是用来练眼神的。。。
我也准备考呢,说得不对的欢迎版上大牛指教。
l******9
发帖数: 48
43
来自主题: Statistics版 - 请教SAS 123题中的17, 57, 68, 72题
if last.department的意思就是只保留是最后一个department的obs到新dataset里,总
共有5个department所有就只有5个obs。这个语句跟
data one;
set two;
by department;
if last.department;
run;
输出结果应该是一样的,你可以试试。
t********o
发帖数: 369
44
来自主题: Statistics版 - 请教SAS Base50中的41题
try to answer your question.
3 overwrites @25, and age 3 means to read age at column 3, so after reading
dateofbirth, name, the pointer goes back to column 3 and read only that
column for age.
At column 3, there is no value for age but a "/", so age value is missing.
you can try put age 1, you will get the first column value for age (0,1,0
for each obs),
age 2, 1,2,1 for each obs;
age 3, no value,
age 4, 0,2,0 and so on.
z**o
发帖数: 149
45
1. set temp(keep=x );
if x>2;
wbh has 8 obs,
x
3
4
5
6
7
8
9
10
2. set temp(in=B);
existed x replaced by new ones; since only 8 obs left,final wbh has 8 rows:
x y
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
g*******r
发帖数: 270
46
也是unix,sas9.2曾经处理过670m obs,近200 column的数据,
一个办法就是只取需要用的column,一般而言也就几(十)个关键column,绝大多数的
是不参与logic运算的,只是最后要populate一下而已。
还有就是第一步就先supset一下,尽可能的减少obs。
最后一点就是注意自己的programming尽可能的efficient,至少逻辑上要最大可能的简
单化,不要重复的join/match,这个就需要搞透彻了整个project的logic.
g******7
发帖数: 1433
47
I have two data sets I want to merge by model
The first data set’s (model) obs is like
“Accord DX”
“Accord LE”
The second data set’s (model obs is just “Accord”,
So is there a way to substr the string before the space in the first data
set, I mean just keep the words before the space, so I can match merge my
two data sets?
Thanks!
w*******9
发帖数: 1433
48
不好意思你误会了,我绝对不会认为你不知道无偏和方差的意思。想想一下有些式样很
难读,所以individual level variance -- vi---会大些,这时候你可以允许hi-mi比
较大;有些式样比较容易读,所以individual level variance会比较小,就不太能允
许hi-mi比较大。所以就应该对(hi-mi)/sqrt(vi) 用t-test。不同的vi序列会导致不
同的结论,而你只知道500个vi中的一个,所以你要假设这500个vi之间有某种联系(比
如相等) 也就是TankerW说的。
BTW,即使vi不全相等,你不除sqrt(vi)的话,你得到的t-test也是个valid level
alpha test (basically because you can treat these obs as iid in a larger
probability space), but the power is inferior to the test that adjusts the
obs by sqrt(vi)。

for
this
of
p***7
发帖数: 535
49
来自主题: Statistics版 - Put an order variable in a smart way in SAS
Obs VISIT CAT
1 0 N
2 0 Mean
3 0 Median
4 0 Minimum
5 1 N
6 1 Mean
7 1 Median
8 1 Minimum
9 2 N
10 2 Mean
11 2 Median
12 2 Minimum
Data is the above.
Now if we want to put an order variable for each visit, we can do 'if then',
but is there a smarter way to do it? We want this:
Obs VISIT CAT order
1 0 N 1
2 0 Mean 2
3 0 Median 3
4 0 Minimum ... 阅读全帖
c********h
发帖数: 330
50
vif是看covariates之间的关系的
如果关心y和单个x的关系,可以画boxplot,也可以分别画出x中属于class1的obs,和x
属于class2的obs,看是不是线性关系,比如属于class1的x值大多数都小于属于class2
的x值
correlation也不会一点用都没有,想麻烦点的话可以用permutation test
可以做univariate logistic regression,看是不是显著等等
现成的command不是很清楚
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)