BookmarkSubscribeRSS Feed
angelicamagpan0
Calcite | Level 5

Screen Shot 2020-02-01 at 5.59.59 PM.png

 

I originally have that and i wanted to change the format so it would look like this for example:

Observation       XML      ZIP

   1                      35         10 

   2                      97         44

   3                     100       190

 

 

I have tried this code:

proc transpose
data = my_data
out = diff_columns_data;
by exec_type;
var input_type;
run;

 

But my result looks like this

Screen Shot 2020-02-01 at 6.05.37 PM.png

 

Any help would be greatly appreciated! Thanks!

3 REPLIES 3
novinosrin
Tourmaline | Level 20
data have;
input type $	exec_time;
cards;
xml	35
xml	97
xml	110
xml	250
xml	190
xml	110
xml	600
zip	10
zip	44
zip	65
zip	77
zip	43
zip	44
;

data temp;
 set have;
 by type;
 if first.type then n=0;
  n+1;
run;

proc sort data=temp;
by n;
run;

proc transpose data=temp out=want;
by n;
var exec_time;
id type;
run;

unison
Lapis Lazuli | Level 10

Try double-transpose: (1) transpose by type, (2) by _name_:

data have;
input type $ exec_time;
cards;
xml 35
xml 97
xml 110
xml 250
xml 190
xml 110
xml 600
zip 10
zip 44
zip 65
zip 77
zip 43
zip 44
;
run;

proc transpose data=have out=have_trx;
by type;
var exec_time;
run;

proc transpose data=have_trx out=want(drop=_name_);
by _name_;
id type;
var col:;
run;
-unison

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
  • 3 replies
  • 1005 views
  • 2 likes
  • 4 in conversation