Sorting Datastream/Bloomberg data

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Sorting Datastream/Bloomberg data

Hi SAS users,

I have uploaded data from Bloomberg and the data is sorted in a columns as follow

 

DateCompany-ACompany-BCompany-C
date-1Returns-A-1Returns-B-1Returns-C-1
Date-2Returns-A-2Returns-B-2Returns-C-2
Date-3Returns-A-3Returns-B-3Returns-C-3

 

I would like to sort the data this way

 

DataComanyNameReturns
Date-1Company-AReturns-A-1
Date-1Company-BReturns-B-1
Date-1Company-CReturns-C-1
Date-2Company-AReturns-A-2
Date-2Company-BReturns-B-2
Date-2Company-CReturns-C-2
Date-3Company-AReturns-A-3
Date-3Company-BReturns-B-3
Date-3Company-CReturns-C-3

 

 

I have attached a sample of the dataset.

 

Many thanks for your help.


Accepted Solutions
Solution
‎06-08-2018 08:17 AM
Super User
Super User
Posts: 9,599

Re: Sorting Datastream/Bloomberg data

Posted in reply to Yazeed_10

Not tested, post test data in the form of a datastep!

So untested but:

proc transpose data=have out=want;
  by date;
  var company:;
run;

View solution in original post


All Replies
Super User
Posts: 10,280

Re: Sorting Datastream/Bloomberg data

Posted in reply to Yazeed_10

Do a proc transpose by date with var company:

For code fitting a dataset, please post that dataset in the form of a data step; see my footnotes for help.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
New Contributor
Posts: 4

Re: Sorting Datastream/Bloomberg data

Posted in reply to KurtBremser

Thank you for replaying 

Solution
‎06-08-2018 08:17 AM
Super User
Super User
Posts: 9,599

Re: Sorting Datastream/Bloomberg data

Posted in reply to Yazeed_10

Not tested, post test data in the form of a datastep!

So untested but:

proc transpose data=have out=want;
  by date;
  var company:;
run;
New Contributor
Posts: 4

Re: Sorting Datastream/Bloomberg data

Thank you very much for the solution, it works. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 147 views
  • 1 like
  • 3 in conversation