Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Transpose rows to cols

Hi all,

I'm looking for a solution where I need to transpose a table from rows to columns. The example below works as intended, but I have about 400 ProdID's, any suggestions how to solve this in a smart way?

Thanks,

Jonas

OrgData:

load  *Inline

[Knumber, ProdID, Value

1,6,1000

2,7,2000

3,8,3000

4,9,4000

5,10,5000

];

RowsToCols:

LOAD Knumber,

           ProdID AS Prod1,

           Value

RESIDENT OrgData

WHERE ProdID = '6';

CONCATENATE LOAD Knumber,

           ProdID AS Prod2,

           Value

RESIDENT OrgData

WHERE ProdID = '7';

CONCATENATE LOAD Knumber,

           ProdID AS Prod2,

           Value

RESIDENT OrgData

WHERE ProdID = '8';

// ProdID = 9, 10 e.t.c ...

DROP TABLE OrgData;

3 Replies
swuehl
MVP
MVP

MK_QSL
MVP
MVP

OrgData:

load  *Inline

[Knumber, ProdID, Value

1,6,1000

2,7,2000

3,8,3000

4,9,4000

5,10,5000

];

Generic Load * Resident OrgData;

Drop Table OrgData;

Not applicable
Author

Hi Jonas, I just have a problem like that.

I suggest you to see:

- Option TANSPOSE acquiring data from external source (not inline)

  or

- CROSSTABLE