BookmarkSubscribeRSS Feed
R_Chung
Quartz | Level 8

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.

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
R_Chung
Quartz | Level 8

Sorry I am using sas di tools not sas code

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


dharmana01
Fluorite | Level 6

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

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1393 views
  • 0 likes
  • 4 in conversation