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? 🙂
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.