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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 965 views
  • 0 likes
  • 4 in conversation