数据还是来自little sas book,3th, page 79.
数据及程序如下所示:
/* Pumpkin.dat */
Alicia Grossman 13 c 10-28-2003 7.8 6.5 7.2 8.0 7.9
Matthew Lee 9 D 10-30-2003 6.5 5.9 6.8 6.0 8.1
Elizabeth Garcia 10 C 10-29-2003 8.9 7.9 8.5 9.0 8.8
Lori Newcombe 6 D 10-30-2003 6.7 5.6 4.9 5.2 6.1
Jose Martinez 7 d 10-31-2003 8.9 9.510.0 9.7 9.0
Brian Williams 11 C 10-29-2003 7.8 8.4 8.5 7.9 8.0
/* Program */
DATA contest;
INFILE 'c:\MyRawData\Pumpkin.dat';
INPUT Name $16. Age 3. +1 Type $1. +1 Date MMDDYY10.
(Scr1 Scr2 Scr3 Scr4 Scr5) (4.1);
AvgScore = MEAN(Scr1, Scr2, Scr3, Scr4, Scr5);
DayEntered = DAY(Date);
Type = UPCASE(Type);
PROC PRINT DATA = contest;
TITLE 'Pumpkin Carving Contest';
RUN;
疑问:
1.为什么input 行,Age 3. +1 Type $1. +1 ,这里的+1针对哪个变量加的?是什么意思?
2. (Scr1 Scr2 Scr3 Scr4 Scr5) (4.1); 为什么5个score变量外要有括号,后面的(4.1)是什么意思?
3.我把数据存为txt文件到电脑,写入上面的程序,log日志提示正常,output除了表格结构和name值正确外,其余的变量值除4个人错误的值外,大多都是".",好像是缺失值的概念,为什么呢?我照着写的程序如下:
data px1.pumpkin;
infile'c:\users\WW\work\sas\little book,code\3.2.txt';
input name $16. age 3. +1 type $1. +1 Date MMDDYY10.
(scr1 scr2 scr3 scr4 scr5) (4.1);
avgscore = MEAN (scr1, scr2, scr3, scr4, scr5);
dayenterd= DAY(Date);
proc print data=px1.pumpkin;
title'pumpkin contest';
run;
output:
ObsnameagetypeDatescr1scr2scr3scr4scr5avgscoredayenterd
1Alicia Grossman1........
2Matthew Lee.........
3Elizabeth Garci.........
4Lori Newcombe.........
5Jose Martinez....510..510.
6Brian Williams1........
问题比较多,不好意思。
敬请赐教,谢谢!