楼主: clark3721
1413 2

一段代码报错,高手求助啊 [推广有奖]

  • 0关注
  • 0粉丝

大专生

1%

还不是VIP/贵宾

-

威望
0
论坛币
16 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
536 点
帖子
21
精华
0
在线时间
44 小时
注册时间
2008-12-19
最后登录
2016-11-10

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Proc format;
* create value labels for schtyp;
  value scl 1='public'
            2='private';

*create value labels for grade;
  value adcdf 0 = 'F'
              1 = 'D'
              2 = 'C'
              3 = 'B'
              4 = 'A';

*create value labels for female;
  value fm 1 = 'female'
           0 = 'male';
Run;
*create data file hs1 label it;
data hs1(label='high school and beyond');

  *read in the sas file f:\sas_data\hs0;
  set 'f:\sas_data\hs0';

  *label the variable schtyp;
  label schtyp='type of school';

  * apply value labels to schtyp;
  format schtyp scl.;

  *the if-then statements create a new  variable, called prog, which is
    numeric variable;
  if prgtype = 'academic' then prog = 1;
  if prgtype = 'general' then prog = 2;
  if prgtype = 'vocational' then prog = 3;

  *create a new variable, called female,which is idential to the variable gender;
  *and then use drop statement to remove the variable gender from the dataset;
  female = gender;
  drop gender;

  *label the variable prog;
  label prog = 'type of program';

  *label the variable female;
  label female = "student's gender";

  *apply value labels to female;
  format female fm.;

  *the if statement recodes values of 5 in the variable race to be missing (.);
  if race = 5 then race= .;

  *create a variable called total that is the sum of read, write, math, and science ;
  total = read + write + math + science;

  *create a variable statements recode the variable total into the variable grade;
  if (total < 80) then grade = 0;
  if (80 <= total < 110) then grade= 1;
  if (110 <= total < 140) then grade= 2;
  if (140 <= total < 170) then grade= 3;
  if (total >= 170) then grade= 4;
  if (total= .) then grade= .;

  *label the variable grade;
  label grade ='combined grades of read write math and science';

  *apply value labels to variable grade';
  format grade abcdf.;
Run;


log里面报错!
110    format grade abcdf.;
                    ------
                    48
ERROR 48-59: The format ABCDF was not found or could not be loaded.
为什么会这样啊,高手求助啊!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:高手求助 Statements statement Variable Statemen 求助 高手 代码

沙发
honghejing 发表于 2011-6-16 08:47:11 |只看作者 |坛友微信交流群
value adcdf 0 = 'F'
              1 = 'D'
              2 = 'C'
              3 = 'B'
              4 = 'A';


你定义的format是adcdf, 而用的是abcdf,所以会出现错误

使用道具

藤椅
clark3721 发表于 2011-6-16 09:33:46 |只看作者 |坛友微信交流群
honghejing 发表于 2011-6-16 08:47
value adcdf 0 = 'F'
              1 = 'D'
              2 = 'C'
              3 = 'B'
              4 = 'A';


你定义的format是adcdf, 而用的是abcdf,所以会出现错误
谢谢楼上,原来是打错了!

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-14 02:12