I have a data file dat.txt like
no chn math eng
1 93 88 74
2 65 33 90
3 78 69 83
I want a new data like
id subject score
1 chn 93
1 math 88
1 eng 74
2 chn 65
2 math 33
2 eng 90
3 chn 78
3 math 69
3 eng 83
Using R, I can achieve that by
dat1=read.table("dat.txt",head=T)
dat1=dat1[,-1]
n=dim(dat1)[1]
p=dim(dat1)[2]
id=gl(p,n)
subject=rep(names(dat1),n)
score=as.vector(t(dat1))
dat2=data.frame(id,subject,score)
I am new to SAS and I try
DATA dat1;
INFILE 'dat.txt' firstobs=2;
INPUT no chn math eng;
RUN;
Then I don't know what else to do...