data have;
input byvar a b c;
cards;
1 100 200 300
2 400 500 600
;
run;
proc sort data=have;
by byvar;
run;
proc transpose data=have
out=want(keep=byvar _name_ Value1 rename=(_name_=var_name Value1=Value))
prefix=Value;
by byvar;
var a b c;
run;
Can we have the datatype of column "Value" in "want" table set to character datatype during transpose?
If we have a mixed datatype in the input "have" table it is working fine.
I don't think so. Perhaps simply do it in a data step?
data have;
input byvar a b c;
cards;
1 100 200 300
2 400 500 600
;
run;
data want(keep=byvar name Value);
set have;
array _{3} a b c;
do i=1 to dim(_);
name=vname(_[i]);
Value=put(_[i], 8. -l);
output;
end;
run;
I don't think so. Perhaps simply do it in a data step?
data have;
input byvar a b c;
cards;
1 100 200 300
2 400 500 600
;
run;
data want(keep=byvar name Value);
set have;
array _{3} a b c;
do i=1 to dim(_);
name=vname(_[i]);
Value=put(_[i], 8. -l);
output;
end;
run;
@Satish_Parida did you try my code and did it work for you? 🙂
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.