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
Any help would be greatly appreciated! Thanks!
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;
data want;
merge
have (
rename=(exec_time=xml)
where=(input_type = "xml")
)
have (
rename=(exec_time=zip)
where=(input_type = "zip")
)
;
run;
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.