Help using Base SAS procedures

How to change table structure

Reply
Occasional Contributor
Posts: 5

How to change table structure

Hi

I have a dataset that looks like this:

abcde
13579
246810

How to change it to:

CharacterNumber
a1
a2
b3
b4
c5
c6
d7
d8
e9
e10

Thank you in advance!

Super User
Posts: 5,257

Re: How to change table structure

Super Contributor
Posts: 490

Re: How to change table structure

data have;

input a b c d e;

cards;

1 3 5 7 9

2 4 6 8 10

;

run;

proc transpose data=have out=have;

run;

proc transpose data=have out=have;

by _name_;

run;

Super Contributor
Posts: 305

Re: How to change table structure

Hello,

A data step solution:

data have;
input a b c d e;
datalines;
1 3 5 7 9
2 4 6 8 10
;

data want;
set have;
array vars{*} a--e;
do i=1 to dim(vars);
character=vname(vars{i});
number=vars{i};
output;
end;

keep character number;
run;

Ask a Question
Discussion stats
  • 3 replies
  • 272 views
  • 1 like
  • 4 in conversation