c*****p 发帖数: 51 | 1 有如下数据
Seller Year var1 var2 var3
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
...
想变成以下格式新数据
Seller var1 var2 var3 var1 var2 var3 var1 var2 var3
ABC 0 0 0 4 0 0 17 1 1
EFG 32 4 3 45 8 5 50 3 1
...
新数据第2列到第4列为2005的var1到var3,第5列到第7列为2006的var1到var3,第8列到
第10列为2007的var1到var3.
我想用transpo |
|
r**********y 发帖数: 49 | 2 Given the text file COLORS.TXT:
----+----1----+----2----+----
RED ORANGE YELLOW GREEN
BLUE INDIGO PURPLE VIOLET
CYAN WHITE FUCSIA BLACK
GRAY BROWN PINK MAGENTA
The following SAS program is submitted:
data WORK.COLORS;
infile 'COLORS.TXT';
input @1 Var1 $ @8 Var2 $ @;
input @1 Var3 $ @8 Var4 $ @;
run;
What will the data set WORK.COLORS contain?
A
Var1 Var2 Var3 Var4
------ ------ ------ ------
RED ORANGE RED ORANGE
BLUE IND... 阅读全帖 |
|
e*******e 发帖数: 75 | 3 我再用survival analysis 作分析的时候,用了下面的程序却发现问题:
%macro eun5(var1,var2,var3,var4,var5,var1T,var2T,var3T,var4T,var5T);
PROC PHREG DATA=ONE;
MODEL SURV*CENSOR(1)= &VAR1 &VAR2 &VAR3 &VAR4 &VAR5 &VAR1T &VAR2T &VAR3T &
VAR4T &VAR5T;
&VAR1=VAR1*LOG(SURV);
&VAR2=VAR2*LOG(SURV);
&VAR3=VAR3*LOG(SURV);
&VAR4=VAR4*LOG(SURV);
&VAR5=VAR5*LOG(SURV);
PROPORTIONALITY_TEST: TEST &VAR1T, &VAR2T, &VAR3T, &VAR4T, &VAR5T;
%MEND;
%EUN5 (YR1,YR2,YR3,YR4,YR5,YR1T,YR2T,YR3T,YR4T,YR5T);
最后总是出现:
error: variable var5 is not found |
|
R******d 发帖数: 1436 | 4 回头看一下,前面写得有点脱裤子放屁
data test;
input var1 $ var2 var3;
datalines;
a . 1.1
a 5 .
a 6 .
b 5 0
b 5 0
b 7 .
;
run;
proc sql noprint;
create table result as
select *, max(var3) as max, max(var3)>0 as index from test group by var1;
quit;
data result;
set result;
if index=1 then var3=max;
run; |
|
s******r 发帖数: 1524 | 5 proc sort data=test;by var1 descending var3 ;run;
data t1;
set test;
by var1;
if first.var1 then do;
if var3>0 then varx=var3;else varx=.;
end;
var4=max(var3,varx);
retain varx;
drop varx;
run;
|
|
l***o 发帖数: 194 | 6 I try to create a variable: var3 that combined with other 3(char1 char2 and
char4) variables.
since var3 will be too long, so I try to give enough length to it.
let's say 100, but the result var3 still being cut off.
the ideal result
var3 should =
"C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin "C:\DocumentsandSettings\temp\
distractor_analysis.sas"
but it is being cut off.
obviously this length didn't work here. can any expert tell me why?
many many thanks.
mimi
data progs;
var1="distractor_analy |
|
s********e 发帖数: 68 | 7 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
请问应该怎么做呢? |
|
t**j 发帖数: 418 | 8 data a;
set b;
by var1 var2;
if first.var1 or first.var2 then var4=var3;
retain var4; var4=var4*var3;run;
why for observations are first.var1 or first.var2, var4 is the square of
var3 but not var3?
thanks a lot! |
|
p********1 发帖数: 1011 | 9 一共6个independent variables。从这个output上看,哪些variables是好的
predictors?
开始的那些note“!= 0 predicts failure perfectly”
是什么意思? 怎么解决?
logistic y i.var1 i.var2 i.var3 i.expect i.pwar i.open
note: 1.var1 != 0 predicts failure perfectly
1.var1 dropped and 14539 obs not used
note: 2.var1 != 0 predicts failure perfectly
2.var1 dropped and 4903 obs not used
note: 4.var2 != 0 predicts failure perfectly
4.var2 dropped and 96 obs not used
note: 4.var3 != 0 predicts failure perfectly
4.var3 dro... 阅读全帖 |
|
t********m 发帖数: 939 | 10 原data set如下:
ID Session var1 var2 var3 var4
1 1 10 . .
1 1 . 20 .
1 1 . . 30
1 1 . . . black
1 2 11 . .
1 2 . 22 .
1 2 . . . white
想要得到的data set如下:
ID Session var1 var2 var3 var4
1 1 10 20 30 black
1 2 11 22 . white
所用的程序如下:
proc sql;
create table short as
select ID, Session,
max(var1) as var1,
max(var2) as var2,
max(var3) ... 阅读全帖 |
|
j******o 发帖数: 127 | 11 If you really want data step, may try below:
Sort your data HAVE by var1 var2 var3 first.
data obtain;
length lag_var3 $8;
set have;
by var1 var2 var3;
lag_var3=lag(var3);
if first.var2 then call missing(lag_var3, levels);
if var3^=lag_var3 then levels+1;
if last.var2;
keep var1 var2 levels;
run;
only |
|
d*****o 发帖数: 6 | 12 小女工作中碰到一个SQL问题。。由于现在还是个SQL 菜鸟,对此问题很是挠头。。
举例
id var1 var2 var3
1 A B B
1 B C B
1 A B C
2 A A B
2 A A B
2 C C B
3 C A A
3 B A A
3 A A A
如果要写一个logic选择每个id只keep一个,条件是优先选有c的,其次是b.最后是a.
还有一点是先看var3再看var2,最后是var1
象id=1.var3里面优先选c所以要keep这个obs,其他delete
id=2,var3里面都相同,所以看var2,只有A和B情况下优先选B,所以就keep第一个
record
以此类推。。。
这个code在SQL上如何实现呢?或者在SAS可以实现的话也可以。 |
|
k*******a 发帖数: 772 | 13 you can create a score for each obs, then find the maximum score, for
example
data test;
input id var1 $ var2 $ var3$;
datalines;
1 A B B
1 B C B
1 A B C
2 A A B
2 A A B
2 C C B
3 C A A
3 B A A
3 A A A
;
proc sql;
select *, 100*((var3='C')*3 + (var3='B')*2 + (var3 = 'A'))
+ 10*((var2='C')*3 + (var2='B')*2 + (var2 = 'A'))
+ ((var1='C')*3 + (var1='B')*2 + (var... 阅读全帖 |
|
l****u 发帖数: 529 | 14 proc sql;
create table two as
select *, case when min(var3)=max(var3) then ' ' else max(var3) end as id3,
case when min(var2)=max(var2) then ' ' else max(var2) end as id2,
case when min(var1)=max(var1) then '' else max(var1) end as id1
from test
group by id
having var3=id3 or(id3=' 'and var2=id2) or (id3=''and id2=''and var1=id1);
quit; |
|
w****c 发帖数: 10 | 15 one question about regular expression:
assuming we have statement as following:
%var1%/dir:%var2%/dir:%var3%/dir
in vi, it is expected that using s/%\(.*\)%/$\1/g the above
could be converted to "$var1/dir:$var2/dir:$var3/dir".but
I found that it wound up with "$var1%/dir:%var2%/dir:%var3/dir",
that is, vi searchs for largest matchup. How could I get the
fewest match up?
it is very interesting question. hope unix guru could help me.
Acton |
|
d*******1 发帖数: 854 | 16 例子
ID VAR1 VAR2 VAR3
1 1 2 3
2 4 5 6
转化成:
ID VARNAME VALUE
1 VAR1 1
1 VAR2 2
1 VAR3 3
2 VAR1 4
2 VAR2 5
2 VAR3 6
column |
|
a***r 发帖数: 420 | 17 抛砖引玉
#original matrix: A
#new matrix: X
#number of obs:n
#number of var:nvar
> A
var1 var2 var3 var4 var5
1 1 2 3 4 5
2 6 7 8 9 10
3 11 12 13 14 15
4 16 17 18 19 20
>n=4
>nvar=5
>value <-as.vector(t(A))
>varname <-rep(colnames(A),n)
>ID <-sort(rep((1:n),nvar))
>X <-data.frame(cbind(ID,varname,value))
ID var value
1 1 var1 1
2 1 var2 2
3 1 var3 3
4 1 var4 4
5 1 var5 5
6 2 var1 6
7 2 var2 7
8 2 var3 |
|
R******d 发帖数: 1436 | 18 不知道我理解对了不
data test;
input var1 $ var2 var3;
datalines;
a . 1.1
a 5 .
a 6 .
b 5 0
b 5 0
b 7 .
;
run;
proc sql noprint;select distinct var1 into:vars separated by ' ' from test;quit;
proc sql noprint;select count(distinct var1) into:nvar from test; quit;
%macro test;
%do i=1 %to &nvar;
proc sql noprint;
create table tmp as
select *,max(var3>0) as index,max(var3) as max from test where var1="%qscan(&vars,&i,' ')";
quit;
proc append base |
|
G*****u 发帖数: 1222 | 19 我现在一般用sql 好久没用sas sql了
sql语句应该是 (假设大数据是large,小数据是small,共同的variable是A
select var1, var2, var3,
case when A in (select A from small) then 'Patient' else 'Non-Patient' end
as indicator
from large
group by var1, var2, var3
having case when A in (select A from small) then 'Patient' else 'Non-Patient
' = 'Patient'
这个是病人的数据
把最后一句换成
having case when A in (select A from small) then 'Patient' else 'Non-Patient
' = 'Non-Patient'
就是非病人的数据
或者简单一点 不多加变量的话
你可以用个sub query来得到病人的数据
select var1, var2, var3
from la |
|
d*******o 发帖数: 493 | 20 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; |
|
S********a 发帖数: 359 | 21 如果有个变量 var1, 有四个值(categorical variable)分别是a,b,c,d,然后我run一个GLM model 1 如下,var2 和 var3也是categorical variables:
model y=var1 var2 var3;
我再把var1细分成4个dummy variables, 如果var1=a则 var1a=1, 否则var1a=0. var1b, var1c, var1d 同理,再run GLM model 2 如下:
model y=var1b var1c var1d var2 var3;
俩个model我都是用var1=a做reference group, 我可以说俩个model是等价的吗?如果可以,为什么STD ERROR,P-VALUE,还有代入同样变量值组合得到的Y不相等呢,虽然差的不太多。 |
|
x*******u 发帖数: 500 | 22 从数据上看第一个变量的长度是10, 但是用你的code读出来结果是这样的:
char1 char2 char3
1 0 / 3 0 0 0 9 .1 4 1
中间还是有空格。
我用proc import读入数据后, log里面是这样的:
data WORK.READASC ;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile 'myfile.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=7 ;
informat VAR1 $21. ;
informat VAR2 $23. ;
informat VAR3 $9. ;
format VAR1 $21. ;
format VAR2 $23. ;
format VAR3 $9. ... 阅读全帖 |
|
e**h 发帖数: 46 | 23 data final;
merge one(where=(year=2004)
rename=(var1=var1_2004 var2=var2_2004 var3=var3_2004))
one(where=(year=2005)
rename=(var1=var1_2005 var2=var2_2005 var3=var3_2005))
one(where=(year=2006)
rename=(var1=var1_2006 var2=var2_2006 var3=var3_2006));
by 农场 地块;
run;
|
|
y**i 发帖数: 1050 | 24 how to know the exact number of one variable level within another variable
level.
how to know the number of level conditioning on another variable
for example the data as following:
VAR1 VAR2 VAR3 VAR4
A a &&& 34
A a %%% 35
A b *** 54
B a ((( 45
B a ### 45
B c ((( 45
B c &&& 76
B d ^^^ 43
C e !!! 12
How can I know there is 2 (&&&, %%%) levels condition on VAR2=a and VAR1=A,
there is 1(**... 阅读全帖 |
|
d*****o 发帖数: 6 | 25 小女子在此跪谢大牛解答,
最后我的方法参考了Kirk君的scoring的方法,还是没骨气的用了sas,,掩面,,
data temp;
set test;
score=100*((var3='C')*3 + (var3='B')*2 + (var3 = 'A'))
+ 10*((var2='C')*3 + (var2='B')*2 + (var2 = 'A'))
+ ((var1='C')*3 + (var1='B')*2 + (var1 = 'A'))
proc sort data=temp;
by id descending score;
run;
data temp1;
set temp;
by id;
if first.id then output;
run;
Kirk君,求问max(calculated score) as maxscore是在每个id下的max score么。。
我试了你的code貌似不能啊。。还有having那部分不会变蓝log里报错。。。。。 |
|
m*******g 发帖数: 3044 | 26 100*((var3='C')*3 + (var3='B')*2 + (var3 = 'A'))
是啥意思? |
|
k*******a 发帖数: 772 | 27 then you can use format to order the way you want
data test;
input id var1 $ var2 $ var3$;
datalines;
1 A B B
1 B C B
1 A B C
2 A A B
2 A A B
2 C C B
3 C A A
3 B A A
3 A A A
;
run;
proc format;
value $fmtest 'C' = 1
'B' = 2
'A' = 3;
run;
data test1;
set test;
var1f = put(var1, $fmtest.);
var2f = put(var2, $fmtest.);
var3f = put(var3, $fmtest.... 阅读全帖 |
|
a**w 发帖数: 60 | 28 I tried to use a data step, but can't get the requested result.
%macro sum;
data a1;
set s;
by var1 var2 var3;
%do i=1 %to 100;
if first.var3 then %do;
sum_QH&i.=0;
sum_QH&i.+QH&i.;
sum_Q=0;
SUM_Q+Q;
if last.var3;
%end;
%end;
run;
data a;
set a1;
%do %i=1 %to 100;
F=sum_QH&i./sum_Q;
%end;
run;
%mend sum;
%sum |
|
A*****s 发帖数: 813 | 29 希望大家能多一些指标制作的讨论
来源:MACD论坛 作者:林夕
主图指标,在大智慧里勾选主图叠加,否则字看不清楚
使用:白K买入。黄K加仓。绿K出局。笑脸买入。黄点出局。X3线向下不可买入,或以
抢反弹思路操做。m,K,R顶底提示背离状态。不做为操作主要依据。买入。卖出应结合
均线法则综合研判。粘合后向上发散为最佳。该指标缺少量元素。应配合成交量综合观
察。寻求多要素共振。
Var1:=EMA(C,3);
Var2:=EMA(C,5);
Var3:=EMA(C,10);
Var4:=EMA(C,20);
Var5:=EMA(C,30);
Var6:=(Var2+Var3+Var4+Var5)/4;
Var7:=(Var6-REF(Var6,15))/REF(Var6,15)*100;
Var8:=(Var6-REF(Var6,15))/REF(Var6, 15)*100;
Var9:=EMA(Var7,8);
STICKLINE(Var7<1*REF(Var7,1),h,l,0.5,0),COLORBLUE;{蓝-持币}
STICKLINE(Var7<1*REF(Var7,1),o,c |
|
a**********s 发帖数: 588 | 30 int main()
{
Derived Var1;
>>>> construct var1
>>>> Constructor: Base
>>>> Constructor: Derived
Base Var2(Var1);
Derived Var3(Var1);
>>>> The construction of above wont print anything
>>>> since the default copy constructs are done silently
return 0;
>>>> UPON RETURN <<<<
>>>> destruct var3
>>>> Destructor : Derived
>>>> Destructor : Base
>>>> destruct var2
Destructor : Base
>>>> destruct var1
Destructor : Derived
Destructor : Base
} |
|
e****e 发帖数: 179 | 31 I have a data file like this:
A B C D
1 2 3 4
2 3 3 34
* * * *
I want to read these number and assign them to some variables, something like:
1st time:
var1=1, var2=2 var3=3, var4=4
then do something with these Var*
then 2nd time
var2=2, var2=3, var3=3 var4=34
then do something....
and so on.
How to do it in C shell script?
Thanks.
cat |
|
p********a 发帖数: 5352 | 32 ☆─────────────────────────────────────☆
Bighappy (快乐大大大) 于 (Fri Apr 6 14:47:46 2007) 提到:
大侠帮忙看看下面的程序:
data dataA;
input var1 var2;
datalines;
1.2 2.0
4.2 3.2
3.8 1.8
6.0 9.3
7.5 5.4
8.6 7.2
;;;;
data dataB;
input var3 var4;
datalines;
2.1 2.4
2.3 7.2
3.4 2.8
9.4 5.5
5.5 5.9
7.8 7.2
1.1 1.4
4.5 6.5
;;;;
data new;
merge dataA dataB;
run;
proc print; run;
产出的结果如下:
Obs var1 var2 var3 var4
1 1.2 2.0 2.1 |
|
f****7 发帖数: 398 | 33 请教大家一个关于stepwise programming的问题,多谢大家宝贵的时间:
有一个dataset含有101个变量,现在希望依次找出前100个变量中哪些和最后一个变量
的有相关关系。解决的步骤是
1.找出correlation最高的var1,将var1与前100个变量中剩下99个variable分别相加,
得到一组新的variables
2.从新的99个变量中找出correlation最高的那个变量var2, 此var2实际是原dataset中
的var1+var2,并将var1,var2与原100个变量中剩下98个变量相加,得到一组新的
variables
3.从新的98个变量中找出correlation最高的变量var3=(var1+var2+var3)
4.重复以上步骤,直到每次运算中最高的correlation与前一次相比不再增加。
我对此类编程没有经验,现在还徘徊在到底是用sas还是r来处理的阶段,希望大家多多
指教,不甚感激。 |
|
d*******1 发帖数: 854 | 34 比如:
ID1 ID2 var1 var2 var3
A 1 10 44 1
A 1 10 44 2
A 2 11 3 3
A 2 11 3 4
B 3 12 4 5
B 3 12 4 6
B 4 20 10 7
作为一个DATAFRAME, 转化成如下:
ID1 ID2 var1 var2 var3
A 1 10 44 1
A 2 11 3 3
B 3 12 4 5
B 4 20 10 7
换句话说, var1 and var2 的值对每一个ID1xID2都是unique的, var取第一个值就可
以了。
用了aggregate好像不赶趟:
test<-aggregate(data[,3:4], list(data[,1:2]), mean)
Error in sort.list(y) :
'x' must be atomic for 'sort.li |
|
o****o 发帖数: 8077 | 35 > tbl<-read.table('c:/testtble.txt', header=T)
> tbl
ID1 ID2 var1 var2 var3
1 A 1 10 44 1
2 A 1 10 44 2
3 A 2 11 3 3
4 A 2 11 3 4
5 B 3 12 4 5
6 B 3 12 4 6
7 B 4 20 10 7
> tbl[!duplicated(tbl[,-5]),]
ID1 ID2 var1 var2 var3
1 A 1 10 44 1
3 A 2 11 3 3
5 B 3 12 4 5
7 B 4 20 10 7
>
> |
|
p********a 发帖数: 5352 | 36 ☆─────────────────────────────────────☆
fff007 (felix) 于 (Mon Mar 8 15:09:01 2010, 美东) 提到:
请教大家一个关于stepwise programming的问题,多谢大家宝贵的时间:
有一个dataset含有101个变量,现在希望依次找出前100个变量中哪些和最后一个变量
的有相关关系。解决的步骤是
1.找出correlation最高的var1,将var1与前100个变量中剩下99个variable分别相加,
得到一组新的variables
2.从新的99个变量中找出correlation最高的那个变量var2, 此var2实际是原dataset中
的var1+var2,并将var1,var2与原100个变量中剩下98个变量相加,得到一组新的
variables
3.从新的98个变量中找出correlation最高的变量var3=(var1+var2+var3)
4.重复以上步骤,直到每次运算中最高的correlation与前一次相比不再增加。
我对此类编程没有经验,现在还徘徊在到底是用sa |
|
w*****y 发帖数: 130 | 37 请问在使用proc corr检验两个变量时,如何输出pearson test's significant level到指定
的变量?
另外有一组数据
var1,var2,var3
a,100,0.05
a,200,miss
b,100,-0.05
b,200,-0.05
。。。
请问如何输出obervations( when var3>0,output 其所在的整组(var1=a)的观测值)。 |
|
h******e 发帖数: 1791 | 38 一个繁琐的方法:
data test;
input var1 $ var2 var3;
datalines;
a . 1.1
a 5 .
a 6 .
b 5 0
b 5 0
b 7 .
;
run;
data t1;
set test;
by var1;
if first.var1 then var4 = 1;
else if first.var1 = 0 and last.var1 = 0 then var4 = 2;
else if last.var1 then var4 = 3;
run;
proc transpose data = t1 out = t2;
by var1 var2;
id var4;
var var3;
run;
data t3;
set t2;
if _1 > 0 or _2 >0 or _3 >0 then do;
_1 = 1.1;
_2 = 1.1;
_3 |
|
h******e 发帖数: 1791 | 39 假设如下table已经输出到了sas output窗口里:
Table 1
Study XXXX
var1 var2 var3 .................................
... ... ... .................................
... ... ... ..................................
现在需要加上总页码生成以下table:
Table 1
1 of 3 Study XXXX
var1 var2 var3 .................................
... ... ... .................................
... ... ... ..................................
其思想是将第一个table作为只有一个变量的sas dataset重新读入,然后计算study出现的次数得到总页码。加入总页码后再输出为文本得到第二个table。
一般的做法是第一个tabl |
|
i******r 发帖数: 323 | 40 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; |
|
r*****g 发帖数: 99 | 41 请教:
我有一个dataset 有一下variables:var1, var2, var4, var3
我想把var3 放到var4 前面,
除了把dataset export 到excel 然后借助excel 来switch order.有没有简便易行的
sas code可以解决这个问题呢?
谢谢啦! |
|
h********o 发帖数: 103 | 42 DATA ONE;
INPUT VAR $ @@;
CARDS;
A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14
;
DATA ONE;
SET ONE;
RETAIN ID ;
IF MOD(_N_, 5) = 1 THEN ID + 1;
RUN;
PROC TRANSPOSE DATA = ONE OUT = TWO (DROP = _NAME_ ID
RENAME = (COL1 = VAR1
COL2 = VAR2
COL3 = VAR3
COL4 = VAR4
C... 阅读全帖 |
|
x******n 发帖数: 92 | 43 Sorry can not type Chinese
Suppose we have two tables
Table one:
ID Var1 Var2 Var3.....Var30
1 1 0 0 1
2 0 1 1 0
.
.
.
100 1 1 1 1
Table two:
Var Type
Var1 1
Var2 2
Var3 3
.
.
.
Var30 1
We want to pick out the data in table one that Var type is 1
How to do that using SAS |
|
z*********i 发帖数: 146 | 44 我想输出一个表格
格式如下:
######## VAR1 VAR2 VAR3
######## FREQ % FREQ % FREQ %
FEMALE# 940 49.8 141,84 52.5 57,308 42.2
MALE### 947 50.2 12,844 47.5 78,599 57.8
TOTAL## 1,866 100 27,027 100 135,906 100
VAR1 VAR2 是CHAR , VAR3 是NUM |
|
l******o 发帖数: 3764 | 45 现在有一个dependent variable (dep1), 几个predictors (var1 var2 var3 var4)
var1是个categorical variable,求dep1在var1的几个level上的adjusted means
我以前都这么做(只会这一个)
proc glm data=xxx;
class var1;
model dep1=var1 var2 var3 var4;
lsmeans var1;
run;
但是这次我的var1是ordinary的(其实var1是我把一个continuous variable分成的
quintile),我这样用是不是就把var1的几个categories当成无序的处理了,会lose
power吧?
我记得老师讲过大概应该是先得出var1=0时dep1的值,然后var1=1时dep1的值就是加上
1 x beta of var1, 以此类推,是这样吗?
可是俺不会sas code 请好心的高手指教
多谢多谢 |
|
s******1 发帖数: 178 | 46 I have a data set1
var1 var2 var3
1 . .
2 . .
. 3 .
. 4 .
. . 5
. . 6
and want to get data set2
var1 var2 var3
1 3 5
2 4 6
what kind of sas code I can use?
Thank you very much! |
|
k*******a 发帖数: 772 | 47 这个看你怎么定义合并的方法了, 可以试试下面的看看
data test1;
merge test(keep=var1 where=(var1 ne .))
test(keep=var2 where=(var2 ne .))
test(keep=var3 where=(var3 ne .))
;
run; |
|
y********e 发帖数: 363 | 48 数据简略如下:变量为var0--var48(字符型) 和 number(数值型)。
var0 var3 var6 var9 var12 var18 var24 var36 var48 number
no no no no no yes yes yes yes yes 9
no no no no no yes yes yes yes yes 12
其中number的值是变量名中出现的数值:0,3,6,9,12,18,24,36,48
我想做当知道number时,比较其对应的字符型变量的前两个变量,比如
number=9,我想知道var3是不是no,var6是不是yes,如果两者都满足就output
再比如
number=12时,var6是不是no,var9是不是yes,如果两者都满足就output
我笨想取出每个变量做一个data,然后set起来,用lag/diff做前后比较,但总觉得数
据这样整齐,应该有什么简单办法。
求指点。多谢。 |
|
c**d 发帖数: 104 | 49 in the model: y = var1|var2|var3|var4 @2 /stepwise;
give you all 2-way interactions.
1. using proc contents output the variable name data
2: using proc sql to create a macro variable to paste your variables to be
var1|var2|var3|var4|.....
3: in the model y = &varlist. @2 /stepwise; |
|
q**********9 发帖数: 711 | 50 proc glm 可以用 model y = var1|var2|var3|var4 @2;
但是option 里没有stepwise选项,
proc reg 有stepwise 选项,但是不能用 model y = var1|var2|var3|var4 @2这个命令,
我的sas 里没有proc glmselect 命令,现在该用哪个 proc 命令呢? |
|