Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
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
Posted

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900