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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 434 views
  • 2 likes
  • 4 in conversation