SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Transpose a row

Reply
Contributor
Posts: 48

Transpose a row

Background: I have one row record.

1.png

 

and the expexted result is as follow:

2.png

 

Is there ant methods to perform it efficiently in SAS DI?

As I have tried using transpose transformation and it just allows me to transpose one column to one output column each time, i.e, I need to perform the transformation 2 times to achieve the above results.

Super User
Super User
Posts: 7,711

Re: Transpose a row

Post test data in the form of a datastep in a code window (its the {i} above post area).  At a guess:

data have;
  x1="a"; x2="b"; x3="c"; x4="d";
run;
data want (keep=want:);
  set have;
  array vals{4} x:;
  do i=1 to 4 by 2;
    want1=vals{i};
    want2=vals{i+1};
    output;
  end;
run;
Contributor
Posts: 48

Re: Transpose a row

[ Edited ]

Sorry I am using sas di tools not sas code

Super User
Posts: 9,867

Re: Transpose a row

I would try SAS/IML.
Would you like IML code ?


New Contributor
Posts: 4

Re: Transpose a row

data want (drop = i);
do i = 1 to 2;
input name $ @;
input name1 $ @;
output;
end;
cards;
a b c d
;
run;

Ask a Question
Discussion stats
  • 4 replies
  • 185 views
  • 0 likes
  • 4 in conversation