Desktop productivity for business analysts and programmers

Transpose data with dynamic variable lists

Reply
Contributor
Posts: 22

Transpose data with dynamic variable lists

Hi All,

I have multiple datasets with various number of variables in each dataset and I am trying to transpose them with using one code of loop.

For example, this is what I have got.

SourceLocation256
aaaa
bbbb
cccc

sourcelocation234
abbb

bbbb
caaa

sourceLocation137
accc
baaa
cbbb

............

And I am trying to use VAR _ALL_; but it made source and location columns as variables.

Proc Transpose data=work.comparison_want_&sas_name

out=work.comparison_want_t_&sas_name

name=Location

Label=Search_Engine
Prefix=Ranking;

by Source Location;

var _ALL_;

Run;

New Table from the first table would be like this..

SourceLocationNumbers_ListRanking
aaaa2
aaaa5
aaaa6
bbbb4
bbbb

5

bbbb6
cccc2
cccc5
cccc6

Please pardon my poor explanation... Anyone has an idea ?

Thanks!!

Valued Guide
Posts: 858

Re: Transpose data with dynamic variable lists

It would be helpful to give an example dataset for what you have and the result you are looking for.

Contributor
Posts: 22

Re: Transpose data with dynamic variable lists

Please see revised question. Desired output has been added. Thanks.

PROC Star
Posts: 1,146

Re: Transpose data with dynamic variable lists

If your other columns are numeric, just leave out the VAR statement; the procedure will use all of the variables not named in BY.

Ask a Question
Discussion stats
  • 3 replies
  • 527 views
  • 0 likes
  • 3 in conversation