BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Son_Of_Krypton
Fluorite | Level 6

i have a data as follows 

 

Variable         X

Obs.               12345

 

 

Now I want output like as follows

 

 

Variable  X Y Z A B C

Obs.         1 2 3 4 5 6

 

 

How we can do this 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;
input Variable  $       X ;
cards;
Obs.               12345
;

data w;
set have;
length x1 $5;
array new_x [5] $1 ;
x1=strip(put(x,8.));
call pokelong (x1,addrlong(new_x[1]),length(x1));
run;

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

There is no "6" in the source data. From where do you get it?


@Son_Of_Krypton wrote:

i have a data as follows 

 

Variable         X

Obs.               12345

 

 

Now I want output like as follows

 

 

Variable  X Y Z A B C

Obs.         1 2 3 4 5 6

 

 

How we can do this 


 

Son_Of_Krypton
Fluorite | Level 6
it was a typing mistake there is no "C" and "6" in data
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Why do you want to call column names XYZ ABC?  Doesn't seem good.  Anyways;

data want;
  set have;
  array t{5} $1 y z a b c;
  do i=1 to 5;
    t{i}=char(x,i+1);
  end;
  x=char(x,1);
run;

Note, again no test data in the form of datastep, so guessing on a lot of things!

novinosrin
Tourmaline | Level 20
data have;
input Variable  $       X ;
cards;
Obs.               12345
;

data w;
set have;
length x1 $5;
array new_x [5] $1 ;
x1=strip(put(x,8.));
call pokelong (x1,addrlong(new_x[1]),length(x1));
run;