收藏 分销(赏)

sas习题运行结果.doc

上传人:a199****6536 文档编号:2668979 上传时间:2024-06-04 格式:DOC 页数:6 大小:220.55KB 下载积分:6 金币
下载 相关 举报
sas习题运行结果.doc_第1页
第1页 / 共6页
sas习题运行结果.doc_第2页
第2页 / 共6页


点击查看更多>>
资源描述
程序:简短数据运用datalines或cards直接输入数据进行运算。 运行结果: 方法二:运用format读入数据; 运行结果: You see here that there is a colon preceding each informat. This colon (called an informat modifier) tells SAS to use the informat supplied but to stop reading the value for this variable when a delimiter is encountered. Do not forget the colons because without them. SAS may read past a delimiter to satisfy the width specified in the informat. Colon:冒号;delimiter:定界符(在这里定界符是空格); 冒号的作用是从下一个非空的字符开始,读到下一个空格或者是informat指定的长度为止。 libname learn "E:/SAS1/chapter4"; data learn.Perm; input ID : 3. Gender : 1. DOB : mmddyy10. Height Weight; label DOB="Date of Birth"       Height="Height in inches"           Weight="Weight in pounds";           format DOB date9.; datalines; 001 M 10/21/1946 68 150 002 F 5/26/1950 63 122 003 M 5/11/1981 72 175 004 M 7/4/1983 70 128 005 F 12/25/2005 30 40 ; run; title "Listing of Information"; proc print data=learn.Perm; run; 如果吧ID和GENDER的两个冒号去掉,那SAS读记录的时候, 1. ID只会读取informat中指定的长度,即前三个字符 (如果每行数据前没有空格,那ID的值是正常的); 2. GENDER会是接下来的一个字符,而不会跳过空格,所以GENDER不会读到F和M这两个值。 事实上,这里不用format语句也可以正确输出gender。 只有当数据集中出现sas不能读的格式时,才需要用到format或者informat。如日期:1/1/1995 可以用format date9.将它表示为01Jan1995;如$12345,可以用format dollar5. 将它表示成$12345; 第二题: 程序: 运行结果: Csv(comma separated values)。后缀为.csv的文件就是一种特殊格式的纯文本文件,即是一组字符序列,字符之间以英文字符的逗号或制表符(Tab)分隔。 可以使用记事本创建CSV文件。在保存时直接将后缀改为.csv即可。 第四题: 程序: 结果: 第五题: You want to create a test data set that uses a DATALINES statement to read in values for X and Y. In the DATA step, you want to create a new variable, Z, equal to 100 + 50X + 2X2 – 25Y + Y2. Use the following (X,Y) data pairs: (1,2), (3,6), (5,9), and (9,11). 程序: 结果:
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服