第一个colA列值作为标头和colB值在该特定标头值下 [英] First colA column values as header and colB values are under that particular header value

查看:57
本文介绍了第一个colA列值作为标头和colB值在该特定标头值下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 colA colB 
3 9
5 6
5 6
1 27
3 5
3 14



我希望输出像

1 3 5

27 9 6

0 5 6

0 14 0



第一个colA列值作为header和colB值在该特定标头值下。我可以将第一列值区分为多个标题,第二列值在该特定标题值下。请帮助我

解决方案

您可以使用UPDATE语句。这将采用每个变量的最后一个非缺失值。它需要一个主表和一个更新表,但你可以使用OBS = 0让它以一个空主表开始。



数据有;

输入期间ColA ColB ColC @@;

卡;

1 1。 。 1。 2。 1。 。 3 2 1。 。 2。 2。 3 5。 。 3。 。 8

运行;



数据需要;

更新有(obs = 0)有;

按期间;

run;



data _null_;

set want;

put(_All_)(:);

run;



1 1 2 3

2 1 2.

3 5。 8

colA colB
3   9
5   6
5   6
1   27
3   5
3   14


I want the output like
1 3 5
27 9 6
0 5 6
0 14 0

First colA column values as header and colB values are under that particular header value.how can i differentiate first column values as multiple headers and second column values are under that particular header values.Please help me

解决方案

You can use the UPDATE statement. This will take the last non-missing value for each variable. It wants a master table and an update table, but you can just use OBS=0 to have it start with an empty master table.

data have ;
input Period ColA ColB ColC @@;
cards;
1 1 . . 1 . 2 . 1 . . 3 2 1 . . 2 . 2 . 3 5 . . 3 . . 8
run;

data want ;
update have(obs=0) have ;
by period;
run;

data _null_;
set want;
put (_All_) (:) ;
run;

1 1 2 3
2 1 2 .
3 5 . 8


这篇关于第一个colA列值作为标头和colB值在该特定标头值下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆