SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 1252|回复: 1
打印 上一主题 下一主题

code help

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2012-6-2 03:13:04 | 只看该作者

code help

data a;
input ID Gender$ Age Salary Ques1 Ques2 Ques3 Ques4 Ques5;
datalines;
001 M 23 28000 1 2 1 2 3
002 F 55 76123 4 5 2 1 1
003 M 38 36500 2 2 2 2 1
004 F 67 128000 5 3 2 2 4
005 M 22 23060 3 3 3 4 2
006 M 63 90000 2 3 5 4 3
007 F 45 76100 5 3 4 3 3
;
proc format;
value $gender 'M' = 'Male'
'F' = 'Female'
' ' = 'Not entered'
other = 'Miscoded';
value age low-29 = 'Less than 30'
30-50 = '30 to 50'
51-high = '51+';
value $likert '1' = 'Strongly disagree'
'2' = 'Disagree'
'3' = 'No opinion'
'4' = 'Agree'
'5' = 'Strongly agree';
format Gender $gender.
Age age.
Ques1-Ques5 $likert.
Salary dollar11.2;
proc print data=a;
run;
谁能帮我看下哪错了 怎么 format  不过来呢
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2012-6-2 04:02:32 | 只看该作者

Re: code help

[code:1b5amvcd]data a;
input ID Gender$ Age Salary Ques1 Ques2 Ques3 Ques4 Ques5;
datalines;
001 M 23 28000 1 2 1 2 3
002 F 55 76123 4 5 2 1 1
003 M 38 36500 2 2 2 2 1
004 F 67 128000 5 3 2 2 4
005 M 22 23060 3 3 3 4 2
006 M 63 90000 2 3 5 4 3
007 F 45 76100 5 3 4 3 3
;
proc format;
value $gender
'M' = 'Male'
'F' = 'Female'
' ' = 'Not entered'
other = 'Miscoded';

value age
low-29 = 'Less than 30'
30-50 = '30 to 50'
51-high = '51+';

value likert
1 = 'Strongly disagree'
2 = 'Disagree'
3 = 'No opinion'
4 = 'Agree'
5 = 'Strongly agree';
data aa; set a;
format Gender $gender. Age age.  Ques1-Ques5 likert. Salary dollar11.2;
run;
proc print data=aa;
run;[/code:1b5amvcd]
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-5-6 13:35 , Processed in 0.068316 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表