由买买提看人间百态

topics

全部话题 - 话题: var1
首页 上页 1 2 3 4 5 6 7 下页 末页 (共7页)
S******y
发帖数: 1123
1
# A Python solution --
from collections import deque
#function to clean up leading 'missing' items
def clean_queue(q):
if q[0][0] != 'missing' and q[-1][0] != 'missing':
return q
else:
if q[0][0] == 'missing':
q.popleft()
if q[-1][0] == 'missing':
q.pop()
return clean_queue(q)
in_file = 'C:\\b2_data.txt'
f = open(in_file, 'r')
f.next() #skip column-name header
tmp_var1 = ''
ls = []
for line in f:
var1, var2, date = line.spli
d*******o
发帖数: 493
2
proc sql;
select count(*)-count(var1) as num_missing1, count(*)-count(var2)as num_
missing2
from yourtable
;quit;
b2
发帖数: 427
3
var1 var2 date
1 missing 2010-1-1
1 missing 2010-1-2
1 a 2010-1-3
1 b 2010-1-4
above data is stored in work.test
code is
proc sql;
create table test2 as
select name from dictionary.columns where libname='work' and
memname='test';
quit;
why resulted test2 has no rows?
thanks
A****t
发帖数: 141
4
1000?
data one;
infile "...." dlm=',' lrecl=100000;
input var1-var1000;
run;
s*****n
发帖数: 2174
5
其实就是一个循环, 循环里面包含一个判断. 实现的话在R里也就十几行.
data <- read.table(...)
result <- data.frame(try = 1:1000, output = NA, case = NA)
for (i in 1:1000){
data1 <- data[sample(100000, 10000), ]
data2 <- data[sample(100000, 10000), ]
if (mean(data1$var1) > 0){
fit1 <- lm(...)
result$output[i] <- functionA(data2, fit1$parameter_a)
result$case[i] <- "A"
} else {
fit2 <- glm(...)
result$output[i] <- functionB(data2, fit2$parameter_b)
result$case[i] <- "B"
}
}
hist(result$output[
p*****o
发帖数: 543
6
来自主题: Statistics版 - 再来问一个SAS问题
就是我要给每个OBS随机地从1,2,3,。。。,100中取一个数。但是对于组内而言(
比如VAR1 = A的组),他们不能取同样的数(即WITHOUT REPLACEMENT)。
D******n
发帖数: 2836
7
来自主题: Statistics版 - 再来问一个SAS问题
u mean the order within each group of VAR1?
They will not change.
p*****o
发帖数: 543
8
来自主题: Statistics版 - 再来问一个SAS问题
yea. i mean the order within each group of var1.
they will not change?
interesting...i will read through it again.
Is that b/c of the match_key existing there?
S******y
发帖数: 1123
9
来自主题: Statistics版 - 再来问一个SAS问题
#A Python approach: scramble the oder within a group
import random
var1_list = ['A', 'A', 'B', 'B', 'B', 'C', 'C', 'C', 'D', 'D']
ls_item=[]
ls_int =[]
tmp_var1 =''
for item in var1_list:
if tmp_var1 != item and tmp_var1 !='':
ls_int = range(len(ls_item))
random.shuffle(ls_int)
for index, x in enumerate(ls_item):
print x, ls_int[index]+1 #print out var1, var2
ls_item=[]
ls_int=[]

ls_item.append(item)
tmp_var1 = item

ls_int
b2
发帖数: 427
10
来自主题: Statistics版 - 请教如何这样保存数据 SAS
我的目的是想找到某个变量在某个时间内的异常情况。
1,2,3,5,3,5,“0“,2,5,6
1,3,5,6,6,7,“100“,10,21
100,200,301,203,“0“,120,121
第一行的“0”就正常,后两行引号内的书就不正常,我的数据是面板数据;
place time var1 ... variables i am interested
1,如何找到这些异常呢?试图计算%change everyperiod发现不好用啊,因为1 到 2变化百分百,
但正常阿。
2。发现异常后,(when 当前的观测值满足某一条件时,比如说0 or missing,)然后如何保存前
后5个observations,进一步判断是否真的异常。
y********i
发帖数: 205
11
我最近写了个如下的code,原来的code在definition部分有点问题,所以就把
definition的部分改了下。改之前t值的变化会影响结果的变化,但是我做了一点改动
之后,无论如何改动t值,结果都不变了,而且即使把t删掉,结果也不变。不知道是什
么原因?每次运行,log里都显示没有问题。但是如果把t值设置成0,结果会报错,不
知道有高人能指点下或大致判断下原因不?
proc iml;
/* Used for debugging only */
*reset log print details;
start COptimal(xx)
global (Weight, Var1, b0, b1, b2, t);
/* nrow(xx)=1, ncol(xx)=Nd*2 */
x=shape(xx,nrow(xx)*ncol(xx)/2,2);

F=j(nrow(x),1) || x[,1] || x[
g**a
发帖数: 2129
12
来自主题: Statistics版 - How to work on this dataset?
data one;
infile 'filepath' LRECL=150000;
input @'(''' Var1 10. @@;
run;
proc print data=one;
run;
Assuming the length of the number is 10
change the record length accordingly.

the
,(
a********s
发帖数: 188
13
提示点思路吧。。。
(1)可以先用proc contents输出每个variable name
(2)用 call symput 建立一组macro variables, ex: var1, var2,...
(3) 在proc sql中用DO Loop 算 nmiss(&&var&i)...
这样应该可以实现。 我以前写过一个简单的算每个变量的missing proportion的macro
。找不到在哪里了。。。 相信proc means也很好实现。
g********3
发帖数: 123
14
来自主题: Statistics版 - 请教一个简单问题
请问,读入一个txt file,怎样从第二行开始读?
我用了if _N_>1 then do;
input var1;
end;
貌似不对。
谢谢。
S******y
发帖数: 1123
15
来自主题: Statistics版 - 请问一个sas数据集过滤的问题
#去掉配对的冗余.py
#2010-08-31
#Python 2.6
S1 = 'a b 1\nb a 1\na c 2'
S2 = 'a b 1\nb a 3\na c 2'
d={}
for line in S1.split('\n'):
ls = line.split()[0:2]
val= int(line.split()[2])
ls.sort()
k = ','.join(ls) #sorted [var1 , var2] in text as key
if k not in d:
d[k] = val
else:
d[k] = max(d[k],val) #only keep largest val for duplicate key
for key in sorted(d.keys()):
print key + ',' + str(d[key])
######################################################
z****n
发帖数: 67
16
对下面这个data set我想实现的是针对每一行检查相应的变量var1 到变量var6。 如果
值在0 到
50之间的话,就把每一个相应的变量名称存在一个macro variable,并且以空格隔开。
所以最终
我要的结果是:
根据第1行有个macro variable叫做list1, 在list1里面存有变量var6
根据第2行有个macro variable叫做list2, 在list2里面存有变量var5 var6
根据第3行有个macro variable叫做list3, 在list3里面存有变量var4 var6
根据第4行有个macro variable叫做list4, 在list4里面是空的
并且每一行的新建的宏变量名,都要以该行的行序数结尾,比如1到4行,宏变量名相应
的为list1到list4
关键难点在于实际工作中我有300多个变量,所以必须一开始就把满足条件的变量名存在宏变量里
面,因为宏变量不会有长度的问题。如果先建立一个string变量存储那些满足条件的变量名,然后
再放到宏变量里面结果会有问题。因为string变量的长度会不够(SAS字符变量最大长度是200
Y****a
发帖数: 243
17
来自主题: Statistics版 - 一个SAS问题(transpose?)
transpose 里有 ‘by’ statement
proc transpose data=yourdatename out=outdataname;
var var1 - var3;
by Seller Year;
run;
proc transpose data=outdataname out=newdataname;
var col1;
by Seller;
run;
try something like this, you may need to drop a few variables
s**c
发帖数: 1247
18
来自主题: Statistics版 - 请教怎么样转置?
array vars [30] var1-var30;
do i = 1 to 30;
var = var[i];
output;
end;
drop i;
i******n
发帖数: 839
19
来自主题: Statistics版 - 如何找出没有duplicate的数字[done]
proc freq;
table var1/out=out1;
data out1;
set out1 (where= count=1);
run;
t*********l
发帖数: 778
20
来自主题: Statistics版 - 另外请教rtf 文件中 控制pagebreak
一个很大的表格,
name var1 var2....
a
a
b
b
c
c
用proc report 写的 ,然后 ods到 rtf 文件, 问题是 想 每一个名字占一页,不知道如
何控制
pagebreak
听说 9.2中tagsets 里可以控制pagebreak, 但是从来没看到例子.
感谢!
D******n
发帖数: 2836
21
来自主题: Statistics版 - 海量SAS data的处理
fts,这跟sampling啥关系啊。
难道我要找出所有var1==1的obs的obs number, 我还可以去sampling?
b*t
发帖数: 489
22
来自主题: Statistics版 - A SAS question
In a data set, I want to combine two character variables into one.
For example, var1 = "a", var2="b", and I want to create a new variable
var3="ab". This is similar to the "B1&B2" command, but I just don't know
how to implement this in SAS.
Any suggestion is highly appreciated!
s*******e
发帖数: 1385
23
来自主题: Statistics版 - A SAS question
var3=trim(var1)||var2;
w*******t
发帖数: 928
24
来自主题: Statistics版 - A SAS question
var3=cats(var1,var2);
b*****e
发帖数: 223
25
来自主题: Statistics版 - 问你们个 sas macro 的问题
遇到过几次,就是 macro run 好几次的话,前面一次产生的数据会对下一次 run 造成
错误。比如我在 macro 里说如果 variable A 没值(.)的话,就给它赋 variable B
的值。可是第二次 run macro 的时候,因为这些数据在第一次 run 的时候已经造过了
,导致所有的 variable A 都已经有值了(第一次 run 遗留的么),所以就出现了错
误。
如果这种情况你们一般怎么弄啊?我一般在第二次 run macro 之前清一下所有 macro
内部产生的数据。昨天我这样弄了以后,第二次 run 的时候,居然 macro 里的第一个
ods output 出错,死活告诉我找不到 OneWay.......如果我不清数据就不会有这个错
误,为什么呀为什么
%macro MYTEST (var1=, var2=);
ods output OneWay=MYFREQ;
proc freq data=MYDATA;
tables SEX;
run;
ods output close;
.....
%mend MYTEST;
%... 阅读全帖
D******n
发帖数: 2836
26
来自主题: 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
h******e
发帖数: 1791
27
来自主题: Statistics版 - 问个 sas 也许很简单的问题
transwrd(a, "var1", " ") 然后再去掉空格行不行?
r*****g
发帖数: 99
28
来自主题: Statistics版 - How to change sas dataset column order
请教:
我有一个dataset 有一下variables:var1, var2, var4, var3
我想把var3 放到var4 前面,
除了把dataset export 到excel 然后借助excel 来switch order.有没有简便易行的
sas code可以解决这个问题呢?
谢谢啦!
k*******a
发帖数: 772
29
来自主题: Statistics版 - How to change sas dataset column order
data step 不清楚, 用sql很容易啊
proc sql;
create table new as
select var1,var2,var4,var3
from a;
quit;
w*****e
发帖数: 806
30
来自主题: Statistics版 - How to change sas dataset column order
DATA RENEW;
RETAIN VAR1 VAR2 VAR3 VAR4;
SET OLD;
RUN;
h******n
发帖数: 232
31
来自主题: Statistics版 - 请教SAS LABEL问题。
请问SAS 如何能把var2的label拷给var1。
举例:
x y
1 2
现在y有label叫做"number of mitbbs users". 如何让x也有相同的label。(mannually
input的不算)。
拜谢!
y******6
发帖数: 47
32
来自主题: Statistics版 - mixed models
I have a question about mixed models too. For example, Var1 is location(
cities), Var2 is treatment, Var3 is Time (season) Var4 is Year(2008,2009,
2010). I want to make comparsions to see whether 2008,2009 and 2010 have the
same mean or not within each treatment.
proc mixed data= method=type3;
where treatment='Treatment1';
class Location Time Year;
Model counts=time year time*year;
random location;
run;
Type3 tests of fix effects: year, p-value<0.05
While if I change the random from location to ... 阅读全帖
z**********i
发帖数: 12276
33
来自主题: Statistics版 - SAS question - baozi
用KEEP=VAR1 VAR2...,加在你输出的DATASET后面,怎么样?

for
R*********i
发帖数: 7643
34
来自主题: Statistics版 - SAS question (紧急求助,在线等)
Assume the variable names are var1 - var99:
data xxxx;
set xxx;
array vars [*] $ var: ;
var_sum=0;
do i=1 to dim(vars);
if vars[i]='certain value' then var_sum=1;
end;
drop i;
run;
w****a
发帖数: 114
35
来自主题: Statistics版 - SAS question(ergent)
if n(of var1-var50)=0 then newvar=1;

to
p***r
发帖数: 920
36
purpose: 想要做一个macro 循环调用 display, 输出不同的 survey answer as text,
然 后再根据其内容,人工的输入yes/no,以便于以后的数据分析。
problem: 整个 macro 可以运行,唯一的问题是,display 的 window 在循环调用的时
候不能正确的显示 survey answer. (我是将所有的 survey answer 输出到一连串
macro variable 里面去)。
Any solution or suggestion in proving the code is appreciated
code is here
################################
data surveydata;
input x $40.;
cards;
This is programe is useless
I dont think so
Maybe its usefull
Not very much
;run;
%macro survey;
data _null_;
set surveydat... 阅读全帖
l*****o
发帖数: 61
37
ID Year var1 var2
1 2001 a a
2 2001 a a
2 2002 a a
2 2005 a a
3 2005 a a
3 2006 a a
4 2005 a a
5 2001 a a
5 2002 a a
6 2002 a a
7 2007 a a
鞠躬感谢!
j*********a
发帖数: 232
38
来自主题: Statistics版 - 急问一个call symput问题(SAS)
想在macro中的data step干以下事:
call symput ('var&i', value);
但那个&i怎么放都不对,没法得到var1,var2...
请高手指教。
c******d
发帖数: 98
39
i think he needs the following:
keep var1 var2 var3;
* var is the variable you want to keep in output
s***r
发帖数: 1121
40
来自主题: Statistics版 - SAS proc means qusetion, 3 baozi
How can I estimate t value using the heteroskedasticity-consistent standard
errors in a PROC MEAN (see below)? (NOT in a PROC REG)
proc means data=a1 noprint; var var1; by byvariable;
output out=a2 mean=mean1 t=tret;
run;
3 baozi will be given for the first 3 replies. thanks.
l****y
发帖数: 108
41
来自主题: Statistics版 - 请教个菜鸟的sas问题
var1
1
2
3
4
5
用什么办法求逐级递减的差呢
就是想得到个变量是2-1, 3-2, 4-3,5-4这种呢
看起来好像很简单的,但是我实在不会,在此多谢
f*********8
发帖数: 165
42
sample1 sample2 sample3....sample100
var1
var2
var3
.
.
.
var1000
我想quantile normalize 这100个sample,得到一个reference distribution。 以后有
新的sample,就用这个reference distribution做quantile normalization。
请问版上牛人,这个reference distribution怎末整出来,能给个R code 的例子吗?
多谢。
S********a
发帖数: 359
43
来自主题: Statistics版 - 【包子】弱问个dummy variable问题
model y=var1 var2 var3 /solution;
sorry for misleading you.
l*********s
发帖数: 5409
44
来自主题: Statistics版 - 【包子】弱问个dummy variable问题
how are you certain SAS is using the first level of var1 as reference? By default the opposite is the case.
The coding schemes are all equivalent w.r.t linear transformation. As such,
the statistical characteristics won't change at all. But, the invariance
property is about the full model, not about individual parameters.You are
barking up the wrong tree here.
However, if your predictive estimates are different,even by a slight margin, you have very serious troubles, indicating your coding is wr... 阅读全帖
z*******n
发帖数: 15481
45
来自主题: Statistics版 - 【包子】求percentile问题
Var1 = sumy1^2/n_1- y_1^bar^2
Var2 = sumy2^2/n_1- y_2^bar^2
那些bar都知道 就可以算出那个sum square了
Overal Var = (sum(y1^2)+sum(y2^2))/(n1+n2)-Y^bar^2
Y^bar是overallmean,y1 y2是向量哈

y1i, y2i的信息
a*****3
发帖数: 601
46
来自主题: Statistics版 - 双包子求教:SAS问题
Data Letgo_In;
Input var1-var5;
cards;
11 12 13 14 15
21 13 45 56 30
41 21 13 45 13
;
DATA letgo_out (drop= var:);
Set Letgo;
array var[5] ;
do i=1 to dim(var) ;
if var[i] = 13 then do
row =_N_;
pos = i ;
output letgo_out ;end;
end; RUN;
这个包子还真不难, 就要你一个包子吧。
另外楼主写的诗 每个字我老都认得 连起来却不明白。
k*******a
发帖数: 772
47
来自主题: Statistics版 - 请问如果用SAS 解决这个问题
你可以用array,也可以用proc transpose
如果用transpose你可以:
data b;
set a;
ID=_N_;
run;
proc transpose data=b out=c;
var var1-var4;
by ID;
run;
proc sort data=c;
by ID descending col1;
run;
data d(keep=newvar);
set c;
by ID descending col1;
if first.ID;
newvar=_name_;
run;
d******9
发帖数: 404
48
来自主题: Statistics版 - 请问如果用SAS 解决这个问题
I used array to do it, same results:
proc format;
value position
1='A'
2='B'
3='C'
4='D';
run;
data E(drop=I) ;
set A;
array X(4) A B C D;
do I=1 to 4;
if X(I)= max(A, B, C, D) then Position=I;
end;
Max_Var=put(position, position.);
run;
However, what if the values have ties? say:
var1 var2 var3 var4
9 9 3 4
9 2 9 8
9 9 9 9
????????
l****u
发帖数: 529
49
来自主题: Statistics版 - 请问如果用SAS 解决这个问题
with and w/o ties:
%macro new;
data new(drop=i max);
set yourdata;
max=max( of var1-var4);
length new $8.;
%do i=1 %to 4;
if var&i=max then do;
new="var&i";
output;
end;
%end;
run;
%mend;
%new
o****o
发帖数: 8077
50
来自主题: Statistics版 - 请问如果用SAS 解决这个问题
data _xxx;
input var1 var2 var3 var4;
cards;
2 4 6 7
4 9 7 6
5 2 1 1
7 3 7 3
;
run;
proc transpose data=_xxx out=_xxx2;
run;
proc means data=_xxx2 noprint;
var col1-col4;
output out=_xxx3(keep=v1-v4)
maxid(col1(_name_)
col2(_name_)
col3(_name_)
col4(_NAME_))= v1-v4/autoname;
run;
proc transpose data=_xxx3 out=_xxx3t;
var v1-v4;
run;
d... 阅读全帖
首页 上页 1 2 3 4 5 6 7 下页 末页 (共7页)