Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
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 17-Dec-12 18:57pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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_) (Smile | :) ;
run;

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

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

  Print Answers RSS
0 OriginalGriff 6,656
1 Sergey Alexandrovich Kryukov 6,400
2 CPallini 5,240
3 George Jonsson 3,584
4 Gihan Liyanage 2,625


Advertise | Privacy | Mobile
Web04 | 2.8.140921.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100