标题: 帮我看一下这道题 [打印本页] 作者: shiyiming 时间: 2007-9-23 13:47 标题: 帮我看一下这道题 You have a collection of raw data representing the reading scores on three groups of subjects :control group C,method A group,method B group.The data are arranged so that a group code is followed by one or more scores for that group,and scores for any group can span more than one record of raw data.Write a SAS program that will read the data below and create a SAS data set reading with variables GROUP and SCORE,one set per obervation.
DATA TESTSCORE
C 303 102 150 B 202 C 300 B 450 400 399
420 A 289 280 278
如果只有两个变量的话,是不是结果是这样的呢:
group score
c 303
102
150
300
B 450
400
399
420
A 289
280
278
但是如何把A B C 分离出来呢
thank you作者: shiyiming 时间: 2007-9-24 09:43 标题: Re: 帮我看一下这道题 In sas QQ group,windcloud has answer your question
data testscore(DROP=X);
input x $ @@;
RETAIN G;
if indexc(x,'ABC')=1 THEN DO;
G=X;
END;
ELSE DO;
s=X+0; OUTPUT;
END;
CARDS;
C 303 102 150 B 202 C 300 B 450 400 399
420 A 289 280 278
;
PROC SORT;
BY G;
RUN;作者: shiyiming 时间: 2007-9-24 09:55 标题: Re: 帮我看一下这道题 sas presents the data in this way:
a 289
a 280
a 278
b 202
b 450
......
so if this is what you want, you can use the below program:
data raw(keep=group score);
input t $ @@;
retain group;
if input(t,3.)=. then group=t;
if input(t,3.)^=.;
score=input(t,3.);
cards;
C 303 102 150 B 202 C 300 B 450 400 399
420 A 289 280 278
;
run;
proc sort;
by group /*score,if necessary*/;
run;
proc print;
run;作者: shiyiming 时间: 2007-9-24 12:05 标题: to mzmxly81 非常感谢,不知道你说的In sas QQ group,windcloud has answer your question
不知道你说的qq group在哪本书里有,我们现在用的是the little SAS book,只学了一部分,但是在后面也没有看到有呢?能不能推荐一下书名。谢谢作者: shiyiming 时间: 2007-9-24 12:05 标题: to yxcc1070 非常感谢,记下了,下次遇到这种问题就知道怎末作了作者: shiyiming 时间: 2007-9-24 13:00 标题: Re: 帮我看一下这道题 haha...,是个qq群来的,有兴趣就加吧:26345523