C**********o 发帖数: 658 | 1 Transpose
Does anyone knows how to transpose by more than 1 ID?
The report before transpose looks like :
Branch month product
1 Jan-07 HO 1000
Jan-07 AUTO 1005
Feb-07 HO 1100
Feb-07 AUTO 2000
2 Jan-07 HO 1000
Jan-07 AUTO 1005
Feb-07 HO 1100
Feb-07 AUTO 2000
And after transpose:
Jan-07 Feb-07
HO AUTO HO AUTO
Branch
1 1000 1005 1100 2000
2 1000 1005 1100 |
|
Y****a 发帖数: 243 | 2 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 |
|
p*****o 发帖数: 543 | 3 I have the following data set:
Group Date Credit1 Credit2
M 01/01 600 610
M 01/02 500 510
F 01/01 700 710
F 01/02 400 410
How can i get the following data set using proc transpose...
Date Credit1_M Credit2_M Credit1_F Credit2_F
01/01 600 610 700 710
01/02 500 510 400 410
Proc transpose is really a pian for me since I guess I have been asked 3
times about it here but I just still cant get how to d... 阅读全帖 |
|
l*****k 发帖数: 587 | 4 I can do it in R, but not sure if sas can also handle it.
I have 26 lists, now I want to generate their pairwise overlaps
I did the overlap in R, now the output is
list1 list2 both_up both_down
a c x x
a b x x
a c x x
.
.
.
b a x x
b b x x
.
.
.
list1 is actually list2, the whole paiwise comparison has 26*26 row
can I transform it to matrix format using proc transpose?
the result should have list1 as ro... 阅读全帖 |
|
|
|
w*****1 发帖数: 473 | 7 【 以下文字转载自 Statistics 讨论区 】
发信人: wz99331 (dotti), 信区: Statistics
标 题: 请教proc transpose 问题
发信站: BBS 未名空间站 (Wed Oct 25 15:16:10 2017, 美东)
我想用proc transpose 把long data 转化为wide data,但是转化以后的column name
变成了var1, var2 var3 var4....,而不是原来的probe_id。我用了profix=probe_id,
结果column name 变成了probe_id1, probe_id2...,而不是原来的PROBE_ID,我希望转
化以后的column name 是ILMN_1762337,ILMN_2055271......
下面是 long data的部分数据,从第三个变量开始是sample name,下面的数据是gene
expression level,一共有几百个sample, 几十万个probe.
PROBE_ID SYMBOL 5117-H471Fwk12-... 阅读全帖 |
|
w*****1 发帖数: 473 | 8 【 以下文字转载自 Statistics 讨论区 】
发信人: wz99331 (dotti), 信区: Statistics
标 题: 请教proc transpose 问题
发信站: BBS 未名空间站 (Wed Oct 25 15:16:10 2017, 美东)
我想用proc transpose 把long data 转化为wide data,但是转化以后的column name
变成了var1, var2 var3 var4....,而不是原来的probe_id。我用了profix=probe_id,
结果column name 变成了probe_id1, probe_id2...,而不是原来的PROBE_ID,我希望转
化以后的column name 是ILMN_1762337,ILMN_2055271......
下面是 long data的部分数据,从第三个变量开始是sample name,下面的数据是gene
expression level,一共有几百个sample, 几十万个probe.
PROBE_ID SYMBOL 5117-H471Fwk12-... 阅读全帖 |
|
l*****k 发帖数: 587 | 9 An issue that must have an elegant and simply solution.
I am trying to use transpose on a dataset, however how do
I specify all the variables?
if the are named col1, col1, etc, it is ok to use: var col1-col99
however what if they have random names, I have been trying to export
the data to excel, copy the header(variable name), then paste it back
to sas like
proc transpose data=original out=out;
var test1 result2 test2 result2........;
run;
is there a way to do this without specifying all |
|
c******n 发帖数: 380 | 10 感觉只用transpose够呛,id values只能出现一次,就算是在同一个by group里也有重
复的,估计得连A一起transpose,然后在data step里再output |
|
i******r 发帖数: 323 | 11 data one ;
input Seller $ Year var1 var2 var3;
cards;
ABC 2005 0 0 0
ABC 2006 4 0 0
ABC 2007 17 1 1
EFG 2005 32 4 3
EFG 2006 45 8 5
EFG 2007 50 3 12
;
run;
proc sort data=one; by seller year; run;
proc transpose data=one out=two (drop=_name_);
by seller year;
var var1-var3; run;
proc sort ; by seller year;
run;
proc transpose data=two out=three (drop=_name_) prefix=var ;
by seller year;
var col1; run; |
|
w*****1 发帖数: 473 | 12 【 以下文字转载自 Statistics 讨论区 】
发信人: wz99331 (dotti), 信区: Statistics
标 题: 请教proc transpose 问题
发信站: BBS 未名空间站 (Wed Oct 25 15:16:10 2017, 美东)
我想用proc transpose 把long data 转化为wide data,但是转化以后的column name
变成了var1, var2 var3 var4....,而不是原来的probe_id。我用了profix=probe_id,
结果column name 变成了probe_id1, probe_id2...,而不是原来的PROBE_ID,我希望转
化以后的column name 是ILMN_1762337,ILMN_2055271......
下面是 long data的部分数据,从第三个变量开始是sample name,下面的数据是gene
expression level,一共有几百个sample, 几十万个probe.
PROBE_ID SYMBOL 5117-H471Fwk12-... 阅读全帖 |
|
p*****n 发帖数: 387 | 13 input.txt --》output.txt
我的理解是
把input.txt 第一行数据for1-3 列transpose,然后与第二行数据join
output.txt 最后insert 一列time key
不知道对否?
用sql程序怎么实现?
我sql太弱,一直没有搞定程序。恳请高手指点code。
多谢!
input.txt
ID for1 for2 for3
10 20.1 20.2 20.3
20 20.4 20.5 20.6
output.txt
ID forecast Time Key
10 20.1 1
10 20.2 2
10 20.3 3
20 20.4 1
20 20.5 2
20 20.6 3 |
|
m******t 发帖数: 35 | 14 200,000rows
20 columns
how to transpose it? |
|
i***r 发帖数: 1035 | 15 我有个20 million row * 100 column的文件
需要transpose,大概如下:
11 11 11 11 11...
22 22 22 22 22...
33 33 33 33 33...
44 44 44 44 44...
55 55 55 55 55...
...
to
1122334455...
1122334455...
我现在用的方法很慢,就是每次读一行2个char,比如 11,存到 string, 然后一行一
行的读,往后面加,1122, 112233, 11223344, 1122334455 等等。最后吧string
打出来。
居然要几个小时。
很早以前写了个bash的,时间应该在半小时以内吧。但是我想用python做。请问:
1) 这么慢是因为 不停往后面加东西吗?
2) 怎么变快? |
|
v*******e 发帖数: 11604 | 16
plink直接就有命令来transpose ped文件,产生tped文件。自己去plink网页上搜tped
。python不是万能的,自己编写程序容易出错,费时费力,已经有的工具用好就行了。 |
|
l*******m 发帖数: 1096 | 17 subpixel conv更像一个explicit upsampling filters. transposed conv 应该有像
素叠加吧 |
|
w***g 发帖数: 5958 | 18 已经确认,sub是一种特殊情况的trans. 前者可以用后者实现,后者未必能用前者实现。
subpixel conv更像一个explicit upsampling filters. transposed conv 应该有像 |
|
x******e 发帖数: 42 | 19 現有500 excel files and these file names are stored in another file called
file.dat.
How to quickly import these files (500 excel files) and stored as SAS files
respectly after transposing them?
I wrote the code for a single file, but have to run the macro 500 times with
different numbers. It will be tedious.......... Any other convenient way
by taking advantage of the file.dat?
3xs!!!
%macro dataread(number);
PROC IMPORT OUT= file&number
DATAFILE= "C\chart_data\CR&number..xls"
DBMS |
|
l********g 发帖数: 14 | 20 For PROC TRANSPOSE, what does it mean by saying that the column used for ID
statement can not have duplicate values?
在线等答案!
谢谢! |
|
h******e 发帖数: 1791 | 21 是分组的问题,检查你的by statement后的variables是不是对应多个var statement
后varible的值。或者事实let option 在transpose statement 里。 |
|
n******9 发帖数: 26 | 22 原数据如下:
id a b c
1 0 0 0
1 1 1 0
1 1 1 1
2 0 0 0
2 0 0 0
。。。
想把以上数据转换成
id type response
1 a 0
1 b 0
1 c 0
1 a 1
1 b 1
1 c 0
1 a 1
1 b 1
1 c 1
2 a 0
2 b 0
2 c 0
2 a 0
2 b 0
2 c 1
。。。
原本以为可以用PROC TRANSPOSE 来做转换,可是总也不能转换成我想要的样子。 肯请
大侠们帮我看看,到底能不能用SAS完成转换。
万分感谢! |
|
A*******s 发帖数: 3942 | 23 我看了一下by statement的sas help document,原来
The maximum number of observations in any BY group in the input data set is
two;
所以我能想到的变通方法是
data test;
input id a b c;
cards;
1 0 0 0
1 1 1 0
1 1 1 1
2 0 0 0
2 0 0 0
;
run;
data test;
set test;
row=_N_;
run;
proc transpose data=test out=out(drop=row rename=(_Name_=type col1=response)
);
by row id;
proc print;
run;
Obs id type response
|
|
f*******e 发帖数: 51 | 24 不用transpose
data test;
input id a b c;
cards;
1 0 0 0
1 1 1 0
1 1 1 1
2 0 0 0
2 0 0 0
;
run;
data test;
set test;
type="a"; response=a; output;
type="b"; response=b; output;
type="c"; response=c; output;
keep id type response;
run; |
|
g********d 发帖数: 2022 | 25 data one;
input A B $ C D;
cards;
100 07 1000 40
100 07 1000 40
100 07 1001 30
100 06 1000 10
100 06 1001 0
101 06 1000 20
101 06 1003 70
101 07 1000 0
101 07 1003 0
;
run;
proc sort out=two;by A C B D; run;
data three;
set two;
by A C B D;
if first.D then output;
run;
proc transpose out=fin prefix=D;
by A C;
ID B;
var D;
run; |
|
b******e 发帖数: 539 | 26 把楼上的程序稍微改了一下:
proc sort data=aaa out=bbb nodupkey; by A C B D; run;
proc transpose data=bbb out=fin prefix=D;
by A C;
ID B;
var D;
run; |
|
S******y 发帖数: 1123 | 27 #transpose.py
#Python 2.6
S = '''100 07 1000 40
100 07 1000 40
100 07 1001 30
100 06 1000 10
100 06 1001 0
101 06 1000 20
101 06 1003 70
101 07 1000 0
101 07 1003 0'''
d={}
for line in S.split('\n'):
A, B, C, D = line.split()
keyx = A + ',' + C
if keyx not in d:
d[keyx] = {}
d[keyx][B]= D
print 'A,C,D07,D06' #title row
for k in sorted |
|
d*******o 发帖数: 493 | 28 data one ;
input Seller $ Year var1 var2 var3;
var=var1;output; var=var2;output; var=var3;output;
drop var1-var3;
cards;
ABC 2005 0 0 0
ABC 2006 4 0 0
ABC 2007 17 1 1
EFG 2005 32 4 3
EFG 2006 45 8 5
EFG 2007 50 3 12
;
run;
proc sort data=one; by seller; run;
proc transpose data=one out=two prefix=var; by seller; var var; run; |
|
h******e 发帖数: 1791 | 29 可以根据M和F将原dataset分为两个,然后分别transpose再combine在一起。 |
|
p*****o 发帖数: 543 | 30 SO WE CANT DO IT IN A SIMPLE PROC TRANSPOSE? |
|
h******e 发帖数: 1791 | 31 先把credit1和credit2合并成一个,相应的改group里值,然后一步transpose就行了。 |
|
w*******9 发帖数: 1433 | 32 1-->2: 对transpose不熟,有一个很笨的方法,取俩subset再append。要求按原来的顺
序的话,给原数据加一列标示obs id.
2-->1: 先output成俩subset,再用sql语句merge。 |
|
s*******e 发帖数: 1385 | 33 Sorry, no Chinese input in office.
Is there anyone know how to use SQL, like teradata sql to do SAS proc
transpose? From long format to wide format?
Thanks very much! |
|
w*****1 发帖数: 473 | 34 我想用proc transpose 把long data 转化为wide data,但是转化以后的column name
变成了var1, var2 var3 var4....,而不是原来的probe_id。我用了profix=probe_id,
结果column name 变成了probe_id1, probe_id2...,而不是原来的PROBE_ID,我希望转
化以后的column name 是ILMN_1762337,ILMN_2055271......
下面是 long data的部分数据,从第三个变量开始是sample name,下面的数据是gene
expression level,一共有几百个sample, 几十万个probe.
PROBE_ID SYMBOL 5117-H471Fwk12-B3.AVG_Signal
ILMN_1762337 7A5 18.56415
ILMN_2055271 A1BG 33.11682
ILMN_1736007 A1BG -3.966002
ILMN_2383229 A1CF ... 阅读全帖 |
|
e********r 发帖数: 2352 | 35 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程
语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important
Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小
时,快累死了。
数学题基本上就是脑筋急转弯,举几个例子
1. You have three kinds of magazines, all but two are Times, all but two are
Science, all but two are Nature. How many magazines in total do you have?
3 books
2. Only one of the answers is true
A. All of the below are true
B. All answers are true
C. One of the above is true
D. All of the above are true
E. None of the above ar... 阅读全帖 |
|
f**d 发帖数: 768 | 36 这是一本计算神经科学的优秀著作,全文拷贝这里(图和公式缺),有兴趣的同学可以
阅读
如需要,我可以分享PDF文件(--仅供个人学习,无商业用途)
From Computer to Brain
William W. Lytton
From Computer to Brain
Foundations of Computational Neuroscience
Springer
William W. Lytton, M.D.
Associate Professor, State University of New York, Downstato, Brooklyn, NY
Visiting Associate Professor, University of Wisconsin, Madison
Visiting Associate Professor, Polytechnic University, Brooklyn, NY
Staff Neurologist., Kings County Hospital, Brooklyn, NY
In From Computer to Brain: ... 阅读全帖 |
|
s******c 发帖数: 99 | 37 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程
语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important
Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小
时,快累死了。
数学题基本上就是脑筋急转弯,举几个例子
1. You have three kinds of magazines, all but two are Times, all but two are
Science, all but two are Nature. How many magazines in total do you have?
2. Only one of the answers is true
A. All of the below are true
B. All answers are true
C. One of the above is true
D. All of the above are true
E. None of the above are true
F... 阅读全帖 |
|
s******c 发帖数: 99 | 38 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程
语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important
Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小
时,快累死了。
数学题基本上就是脑筋急转弯,举几个例子
1. You have three kinds of magazines, all but two are Times, all but two are
Science, all but two are Nature. How many magazines in total do you have?
2. Only one of the answers is true
A. All of the below are true
B. All answers are true
C. One of the above is true
D. All of the above are true
E. None of the above are true
F... 阅读全帖 |
|
K****n 发帖数: 5970 | 39 实在没看明白怎么设计的模型。不太明白,是说换个软件算3000次就不傻?是说太慢吗
?就像楼上所说,确实也没多少数据,为啥慢呢。。
是不是拟合的时候为了通用性用了啥迭代算法?你试试直接求解析解呢
AX = b, A是data输入,b是已知输出,求A
A*X*transpose(X) = b*transpose(X)
A = b*transpose(X)*inverse(X*transpose(X))
自己小心一点儿行和列就行了。时间紧任务急,求逆矩阵也不要自己写了,找个啥软件
算算先。 |
|
B********e 发帖数: 10014 | 40 I guess you are right
you can't complete it by elementary transform
actually 'elementary transfrom' is used to keep the equivalence relation bet
ween matrix when we solve the equation system. 'transpose' doesnt do that e
ven though it's also linear transform on real field.
in some sense 'transpose' is as 'elementary' as 'elementary transform'.
and i'm wondering why you want to carry out transpose by 'elementary transfo
rm'? after all, transpose is a simpler operation, you can do it by nothing |
|
z**********i 发帖数: 12276 | 41 来自主题: Statistics版 - sas一问 因为还有其他一些numeric variables一起transpose.
如果,和ID一起transpose,它们也变成character variable了。
这时,我发现日期在这两个datasets里发生了变化:
如果日期按照numeric来transpose,它显示的是days,比如17832;
而如果按照character来transpose,它显示的是mm/dd/yyyy.
下一步,我要与另一个dataset比对日期,所以,我希望是days,比较方便。
但我还想keep ID,因为比对后,我要报告是哪个ID. |
|
A*******s 发帖数: 3942 | 42 涉及变量名的改变的基本上是两种思路,一种是用transpose将变量名变成变量然后改
变,一种是用proc sql's dictionary.table读入变量名到macro variables,然后再用
proc sql或者data step改名。lz的这个问题我觉得用proc transpose更简单些。
data test;
a=1;
b=3;
c=6;
d=3;
e=8;
f=9;
run;
proc transpose data=test out=test1;
run;
data test1;
set test1;
_Name_=cats('col_',put(_N_,$10.));
run;
proc transpose data=test1 out=test2(drop=_Name_);
run; |
|
o****o 发帖数: 8077 | 43 凑个热闹,给个比较冗长但是通用的解法
data test;
input id $1 v1 3 v2 $5-6 v3 8 v4 $10-11;
cards;
a 1 x2 .
a . 3
a . . x4
b 1 x2 .
b . 3
b . . x4
;
run;
proc sql noprint;
select
case
when(type='char') then cat('length ', compress(name), ' $ ',
length, ';')
else cat('length ', compress(name), ' ', length, ';')
end
into :varlist separated by ' '
from sashelp.vcolumn
where libname='WORK' and memname='TEST'
;
quit;
%put... 阅读全帖 |
|
n*s 发帖数: 752 | 44 4. string transpose
import sys
def transpose(input,i):
mystr = list(input)
mystr[i],mystr[i+1] = mystr[i+1],mystr[i]
return ''.join(mystr)
def str_transpose():
print 'input two strings, separated by blank:'
a, b = sys.stdin.readline().split()
size = len(a)
if size != len(b) or sorted(a) != sorted(b):
return 'no way!'
next = [b]
parent = {b:None}
idx = size -1
notFound = True
while notFound:
newstr = []
for x in next:
... 阅读全帖 |
|
n*s 发帖数: 752 | 45 4. string transpose
import sys
def transpose(input,i):
mystr = list(input)
mystr[i],mystr[i+1] = mystr[i+1],mystr[i]
return ''.join(mystr)
def str_transpose():
print 'input two strings, separated by blank:'
a, b = sys.stdin.readline().split()
size = len(a)
if size != len(b) or sorted(a) != sorted(b):
return 'no way!'
next = [b]
parent = {b:None}
idx = size -1
notFound = True
while notFound:
newstr = []
for x in next:
... 阅读全帖 |
|
r*********s 发帖数: 2157 | 46 我用下面的, 然后 C-c o 交换两个windows
;; transpose(interchange) two windows
(defun his-transpose-windows (arg)
"Transpose the buffers shown in two windows."
(interactive "p")
(let ((selector (if (>= arg 0) 'next-window 'previous-window)))
(while (/= arg 0)
(let ((this-win (window-buffer))
(next-win (window-buffer (funcall selector))))
(set-window-buffer (selected-window) next-win)
(set-window-buffer (funcall selector) this-win)
(select-window (funcall selector)))
(setq arg (if (plusp arg) (1- arg) (1+ arg |
|
k***t 发帖数: 769 | 47 This question is to define Ruby classes for vectors and matrices.
Define two classes MyVector and MyMatrix with the methods described be-
low.
A MyVector object represents a row vector while a MyMatrix object repre-
sents a matrix that internally organized as an array of MyVector objects.
Methods for MyVector
1. The initialize method takes an array of integers as argument.
2. The length method returns the size of the vector
3. The * method takes an argument a:
if a is a vector, then it returns t... 阅读全帖 |
|
c****w 发帖数: 565 | 48 Yes, you are right. Thanks a lot for the explanation.
However, I actually want to use the condensed form for implementation. For V
dyadic W, if both symmetric, we can use 6x1 vectors (v, w) to represent
these two. I calculate the condensed V dyadic W as 6x6 matrix by v*transpose
(w). I think the difference between (2) and (3) is v*transpose(w) VS w*
transpose(v). If condensed V dyadic W is symmetric, I think (2) and (3) can
be interchangable.
Really confused by tensorial and matrix formats, I am |
|
g******n 发帖数: 339 | 49 各位老大:
我的问题是这样:
Z1,Z2 are both n*1 random vectors with independent(but not identically
distributed) binary componets:
(Z1j, j=1,...,n),(Z2j,j=1,...,n), suppose the mean vector for Z1 and Z2 are
u1 and u2, respectively, hence the variance matrices for Z1 and Z2 are both
diagonal with components: S1:=diag(u1j*(1-u_1j)),j=1,...,n and S2:=diag(u2j*
(1-u2j)),j=1,...,n, respectively.
V1,V2 are constant n*1 vectors.
What is E[(transpose(Z1) * V1)^4]?
What is E[(transpose(Z1)*V1)^2 *(transpose(Z2)*V2)]? |
|
f*******e 发帖数: 51 | 50 use transpose
data old;
input aabbbbCC ghhjjhCC jggettCC ghggghBB ;
datalines;
1 2 3 4
4 3 2 1
;
run;
proc transpose data=old
out=new;
run;
data new1;
set new;
if substr(reverse(_name_),1,2)="CC" then output;
run;
proc transpose data=new1
out=new2 (drop=_name_);
run; |
|