全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1539 2
2011-06-16
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.
为什么会这样啊,高手求助啊!
二维码

扫码加我 拉你入群

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

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

全部回复
2011-6-16 08:47:11
value adcdf 0 = 'F'
              1 = 'D'
              2 = 'C'
              3 = 'B'
              4 = 'A';


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

扫码加我 拉你入群

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

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

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,所以会出现错误
谢谢楼上,原来是打错了!
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群