亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

SAS Column Output

SAS Day 26: Column Output

Background:

For table outputs, some times we want both the count and an overall percentage for each category rather than a simple number count.
E.g. 75( 74): 75 count represents 74% of the total number in this group. In order to generate this output format, we need the variable count(c1,c2…) and group total (&n1, &n2…).

[caption id=“attachment_1726” align=“alignnone” width=“750”]image

Pexels / Pixabay[/caption]

**Example 1: Single Column **

col1= count ||" ("|| put((count*100/&bign.),4.1) || ")";

Output:

image

Example 2: Multiple Column

Dataset:

image

Desired Output:

image

As we can see the col1 to col4 shows both the count and the percentage for each group.

Solution Code:

data final;
 set all;
array col[4] $40 col1- col4;
array p[4] (&n1 &n2 &n3 &n4);
array c[4] n1 n2 n3 n4;
do i=1 to 4
col[i]= put (coalesce(c[i],0),4.)|| "(" || put (coalesce(c[i],0)/p[i]*100, 5.1) || ")"

Sample dataset code:

%let n1= 10;
%let n2= 5;
%let n3=6;
%let n4=11;

data test;
input c1 c2 c3 c4;
datalines;
. 2 4 5
3 . 4 6
10 3 2 1
0 1 2 9
;
run;

The code was originated from Denish,(i hope i spelled his name correctly :) )

Happy Practicing!💃

點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消