前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >proc-tabulate

proc-tabulate

作者头像
用户1733462
发布2018-06-01 14:29:04
1.3K0
发布2018-06-01 14:29:04
举报
文章被收录于专栏:数据处理数据处理
代码语言:javascript
复制
data boat;
    infile cards;
    input name $ 1-12 port $ move $ type $ price 6.2;   
    cards;
Silent Lady  Maalea  Sail  sch 75.00
America II   Maalea  Sail  yac 32.95
ALoha Anai   Lahaina Sail  cat 62.00
Ocean Spirit Maalea  Power cat 22.00
Anuenue      Maalea  Sail  sch 47.50
Hana Lei     Maalea  Power cat 28.99
Leilani      Maalea  Power yac 19.99
Kalakaua     Maalea  Power cat 29.50
Reef Runner  Lahaina Power yac 29.95
Blue Dolhin  Maalea  Sail  cat 42.95
;
proc tabulate data=boat;
* calss 语句告诉sas哪些变量将数据分成不同部分;
class port move type;
* table 语句可以定义一个表,可以用对歌table语句定义多个表;
* table语句可以在报告中指定三个维度:页、行、列,如果只指定一个维度
  则默认是列维度,如果指定两个,则是行和列;
table port, move,type;

输出两页,行为move,列为type,N表示非缺失值个数

为了方便观察,数据按照move type排序输出

代码语言:javascript
复制
proc sort data=boat;
by move type;
proc print data=boat;
run;

format将price数字格式修改了,注意table语句,页行列,这里只有两个,所以表示move行,Max、price、type都在列中,

代码语言:javascript
复制
proc tabulate data=boat format=DOLLAR9.2;
class move type;
var price;
table move all, max*price*(type all)/BOX='Full Day Excurions' MISSTEXT='none';
    title;
run;

format自定义格式化,修改顶部标语;

代码语言:javascript
复制
proc format;
    value $typ  'cat' = 'catamaran'
                'sch' = 'schonet'
                'yac' = 'yacht';
proc tabulate data=boat format=dollar9.2;
class move type;
var price;
* 使用格式化;
format type $typ.;
* ''可以去除表格顶部变量名,'xxx'可以指定变量名为xxx;
table move all, (type='mean price by type of boat' all)*max=''*price=''
/BOX='Full Day Excurions' MISSTEXT='none';
    title;
run;

使用set在boat中插入一列数据

代码语言:javascript
复制
data length;
    infile cards;
    input length;
    cards;
64
65
60
65
52
110
45
70
50
65
;

* 使用set在boat中插入一列数据;
data newboat;
    set boat;
    set length;
proc print data=newboat;
run;

在table语句中精准格式化输出数字格式

代码语言:javascript
复制
proc tabulate data=newboat;
class move type;
var price;
var length;
format type $typ.;

table move all, max*(price*format=Dollar6.2 length*format=6.0)*(type all);
run;
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.02.22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档