BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASAlex101
Quartz | Level 8

Hi I have a dataset in list format which is an output from powershell that I've cleaned into two columns called Field and Value and it looks like this:

 

Field   Value

ID       1

ColA   123

ColB   ABC

ColC   D1E

ID       2

ColA   456

ColB   DEF

ColC   G6H

.

.

.

 

How do I convert this data into something like:

ID  ColA   ColB   ColC

1    123    ABC    D1E

2    456    DEF    G6H

 

I've tried proc transpose, but it will just transpose all the columns as separate ones. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
data have;
input Field  $ Value $;
cards;
ID       1
ColA   123
ColB   ABC
ColC   D1E
ID       2
ColA   456
ColB   DEF
ColC   G6H
;;;;
run;

data addID;
set have;
retain row;
if field='ID' then row=Value;
run;

proc transpose data=addID out=want ;
by row;
id field;
var value;
run;

proc print data=want;run;

View solution in original post

1 REPLY 1
Reeza
Super User
data have;
input Field  $ Value $;
cards;
ID       1
ColA   123
ColB   ABC
ColC   D1E
ID       2
ColA   456
ColB   DEF
ColC   G6H
;;;;
run;

data addID;
set have;
retain row;
if field='ID' then row=Value;
run;

proc transpose data=addID out=want ;
by row;
id field;
var value;
run;

proc print data=want;run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 827 views
  • 0 likes
  • 2 in conversation